forked from digitalocean/doctl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* apps: add base scaffolding for app dev command subtree * charm templates: change up method signatures for easier use * only use 1.18.x in ci * add internal package to unit test * disable interactive mode * only use logging pager in interactive mode Co-authored-by: Kamal Nasser <[email protected]>
- Loading branch information
Showing
957 changed files
with
121,187 additions
and
1,305 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
"github.com/MakeNowJust/heredoc" | ||
"github.com/digitalocean/doctl/commands/charm" | ||
) | ||
|
||
func main() { | ||
fmt.Println( | ||
charm.Checkmark, charm.CheckmarkSuccess, | ||
) | ||
|
||
fmt.Println( | ||
charm.TextSuccess.WithString("woo!"), charm.TextSuccess.S("woo 2!"), | ||
) | ||
|
||
if err := charm.TemplatePrint(heredoc.Doc(` | ||
--- template --- | ||
This is an example template. | ||
Another line. | ||
{{ success "maybe some success output" }} | ||
{{ success checkmark }} just the checkmark. | ||
{{ success (join " " (checkmark) "good job!") }} | ||
{{ error (join " " (checkmark) "we're both confused.") }} | ||
{{ warning "try again?" }} | ||
{{ error (join " " (crossmark) "there we go.") }} | ||
{{ success (bold "full send let's go!!!!") }} | ||
{{ bold (success "full send let's go!!!!") }} | ||
{{ bold (underline "underline behaves very strangely") }} | ||
{{ underline (bold "underline behaves very strangely") }} | ||
{{ success (underline "underline behaves very strangely") }} | ||
{{ underline (success "underline behaves very strangely") }} | ||
{{ newTextBox.Success.S "i'm in a box!" }} | ||
`), nil); err != nil { | ||
panic(err) | ||
} | ||
|
||
img := "yeet/yote:dev" | ||
dur := 23*time.Minute + 37*time.Second | ||
fmt.Fprintf( | ||
charm.NewTextBox().Success(), | ||
"%s Successfully built %s in %s", | ||
charm.CheckmarkSuccess, | ||
charm.TextSuccess.S(img), | ||
charm.TextWarning.S(dur.Truncate(time.Second).String()), | ||
) | ||
|
||
if err := charm.TemplateBufferedE(charm.NewTextBox().Success(), heredoc.Doc(` | ||
{{ success checkmark }} Successfully built {{ success .img }} in {{ warning (duration .dur) }}`, | ||
), map[string]any{ | ||
"img": img, | ||
"dur": dur, | ||
}); err != nil { | ||
panic(err) | ||
} | ||
|
||
charm.TemplateBuffered(charm.NewTextBox().Success(), heredoc.Doc(` | ||
{{ success checkmark }} Successfully built {{ success .img }} in {{ warning (duration .dur) }}`, | ||
), map[string]any{ | ||
"img": img, | ||
"dur": dur, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,8 @@ func Apps() *Command { | |
}, | ||
} | ||
|
||
cmd.AddCommand(AppsDev()) | ||
|
||
create := CmdBuilder( | ||
cmd, | ||
RunAppsCreate, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package commands | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/digitalocean/doctl/commands/charm" | ||
"github.com/digitalocean/godo" | ||
) | ||
|
||
type componentListItem struct { | ||
spec godo.AppComponentSpec | ||
} | ||
|
||
func (i componentListItem) Title() string { | ||
return i.spec.GetName() | ||
} | ||
func (i componentListItem) Description() string { | ||
desc := []string{ | ||
snakeToTitle(string(i.spec.GetType())) + " component", | ||
} | ||
|
||
if buildable, ok := i.spec.(godo.AppBuildableComponentSpec); ok { | ||
if sourceDir := buildable.GetSourceDir(); sourceDir != "" { | ||
desc = append(desc, "located in ./"+charm.TextHighlight.S(sourceDir)) | ||
} | ||
} | ||
|
||
return strings.Join(desc, "\n") | ||
} | ||
func (i componentListItem) FilterValue() string { | ||
return i.spec.GetName() | ||
} | ||
|
||
func snakeToTitle(s string) string { | ||
return strings.Title(strings.ReplaceAll(strings.ToLower(fmt.Sprint(s)), "_", " ")) | ||
} |
Oops, something went wrong.