Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: conventionalize on <command> in cmd.Use #7143

Merged
merged 4 commits into from May 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/dagger/call.go
Expand Up @@ -16,7 +16,7 @@ var outputPath string
var jsonOutput bool

var callCmd = &FuncCommand{
Name: "call [options] [FUNCTION]...",
Name: "call [options] <command>",
Short: "Call a module function",
Long: strings.ReplaceAll(`Call a module function and print the result.

Expand Down
4 changes: 2 additions & 2 deletions cmd/dagger/config.go
Expand Up @@ -82,7 +82,7 @@ dagger config -m github.com/dagger/hello-dagger
}

var configViewsCmd = configSubcmd{
Use: "views [options] [name]",
Use: "views [options]",
Short: "Get or set the views of a Dagger module",
Long: "Get or set the views of a Dagger module. By default, print the views of the specified module.",
PersistentFlags: func(fs *pflag.FlagSet) {
Expand Down Expand Up @@ -120,7 +120,7 @@ dagger config views -n my-view
return fmt.Errorf("failed to get view patterns: %w", err)
}
viewMap[name] = patterns
viewStrs = append(viewStrs, fmt.Sprintf("%s\n%s\n",
viewStrs = append(viewStrs, fmt.Sprintf("%s\n<%s>\n",
termenv.String(fmt.Sprintf("%q", name)).Bold().Underline(),
strings.Join(patterns, "\n"),
))
Expand Down
2 changes: 1 addition & 1 deletion cmd/dagger/functions.go
Expand Up @@ -43,7 +43,7 @@ var funcCmds = FuncCommands{
}

var funcListCmd = &FuncCommand{
Name: "functions [options] [FUNCTION]...",
Name: "functions [options] [function]...",
Short: `List available functions`,
Long: strings.ReplaceAll(`List available functions in a module.

Expand Down
2 changes: 1 addition & 1 deletion cmd/dagger/gen.go
Expand Up @@ -19,7 +19,7 @@ func newGenCmd() *cobra.Command {
)

var cmd = &cobra.Command{
Use: "gen [options] FILE",
Use: "gen [options] <file>",
Short: "Generate CLI reference documentation",
Long: "Generate CLI reference documentation in the given file path.",
Args: cobra.NoArgs,
Expand Down
12 changes: 3 additions & 9 deletions cmd/dagger/main.go
Expand Up @@ -358,7 +358,7 @@ func sortRequiredFlags(originalFlags *pflag.FlagSet) *pflag.FlagSet {
// Append [required] and show required flags first
requiredAnnotation, found := flag.Annotations[cobra.BashCompOneRequiredFlag]
if found && requiredAnnotation[0] == "true" {
flag.Usage += " [required]"
flag.Usage = strings.TrimSpace(flag.Usage + " [required]")
mergedFlags.AddFlag(flag)
} else {
optionalFlags.AddFlag(flag)
Expand All @@ -371,14 +371,8 @@ func sortRequiredFlags(originalFlags *pflag.FlagSet) *pflag.FlagSet {
return mergedFlags
}

const usageTemplate = `{{ "Usage" | toUpperBold }}

{{- if .Runnable}}
{{.UseLine}}
{{- end}}
{{- if .HasAvailableSubCommands}}
{{ .CommandPath}}{{ if .HasAvailableFlags}} [options]{{end}} [command]
{{- end}}
const usageTemplate = `{{ if .Runnable}}{{ "Usage" | toUpperBold }}
{{.UseLine}}{{ end }}

{{- if gt (len .Aliases) 0}}

Expand Down
4 changes: 2 additions & 2 deletions cmd/dagger/module.go
Expand Up @@ -78,7 +78,7 @@ func init() {
}

var moduleInitCmd = &cobra.Command{
Use: "init [options] [PATH]",
Use: "init [options] [path]",
Short: "Initialize a new Dagger module",
Long: `Initialize a new Dagger module in a local directory.
By default, create a new dagger.json configuration in the current working directory. If the positional argument PATH is provided, create the module in that directory instead.
Expand Down Expand Up @@ -173,7 +173,7 @@ The "--source" flag allows controlling the directory in which the actual module
}

var moduleInstallCmd = &cobra.Command{
Use: "install [options] MODULE",
Use: "install [options] <module>",
Aliases: []string{"use"},
Short: "Add a new dependency to a Dagger module",
Long: "Add a Dagger module as a dependency of a local module.",
Expand Down
2 changes: 1 addition & 1 deletion cmd/dagger/query.go
Expand Up @@ -22,7 +22,7 @@ var (
)

var queryCmd = &cobra.Command{
Use: "query [options] [OPERATION]",
Use: "query [options] [operation]",
Aliases: []string{"q"},
Short: "Send API queries to a dagger engine",
Long: `Send API queries to a dagger engine.
Expand Down
2 changes: 1 addition & 1 deletion cmd/dagger/run.go
Expand Up @@ -20,7 +20,7 @@ import (
)

var runCmd = &cobra.Command{
Use: "run [options] COMMAND",
Use: "run [options] <command>...",
Aliases: []string{"r"},
Short: "Run a command in a Dagger session",
Long: strings.ReplaceAll(
Expand Down
1 change: 1 addition & 0 deletions cmd/dagger/watch.go
Expand Up @@ -12,6 +12,7 @@ import (
var watchCmd = &cobra.Command{
Use: "watch",
Hidden: true,
Args: cobra.NoArgs,
Annotations: map[string]string{
"experimental": "true",
},
Expand Down
12 changes: 6 additions & 6 deletions docs/current_docs/reference/979596-cli.mdx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.