Skip to content

Commit

Permalink
feat: follow Cobra's usage
Browse files Browse the repository at this point in the history
Follow Cobra's usage: https://github.com/spf13/cobra/blob/main/command.go#L52-L60.
But do not differenciate the optional and mandatory args with []

Signed-off-by: grouville <[email protected]>
  • Loading branch information
grouville committed Apr 23, 2024
1 parent 22e40e3 commit f2bdbf3
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 24 deletions.
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 [flags] [<function> [<child-function>...]]",
Name: "call [flags] [function]...",
Short: "Call a module function",
Long: strings.ReplaceAll(`Call a module function and print the result.
Expand Down
2 changes: 1 addition & 1 deletion cmd/dagger/config.go
Expand Up @@ -82,7 +82,7 @@ dagger config -m github.com/dagger/hello-dagger
}

var configViewsCmd = configSubcmd{
Use: "views [flags] [<name>]",
Use: "views [flags] [name]",
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
2 changes: 1 addition & 1 deletion cmd/dagger/functions.go
Expand Up @@ -43,7 +43,7 @@ var funcCmds = FuncCommands{
}

var funcListCmd = &FuncCommand{
Name: "functions [flags] [<function> [<child-function>...]]",
Name: "functions [flags] [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 [flags] <file>",
Use: "gen [flags] [file]",
Short: "Generate CLI reference documentation",
Long: "Generate CLI reference documentation in the given file path.",
Args: cobra.NoArgs,
Expand Down
4 changes: 2 additions & 2 deletions cmd/dagger/main.go
Expand Up @@ -340,7 +340,7 @@ const usageTemplate = `{{ "Usage" | toUpperBold }}
{{.UseLine}}
{{- end}}
{{- if .HasAvailableSubCommands}}
{{ .CommandPath}}{{ if .HasAvailableFlags}} [flags]{{end}} [<command>]
{{ .CommandPath}}{{ if .HasAvailableFlags}} [flags]{{end}} [command]
{{- end}}
{{- if gt (len .Aliases) 0}}
Expand Down Expand Up @@ -424,6 +424,6 @@ const usageTemplate = `{{ "Usage" | toUpperBold }}
{{- if .HasAvailableSubCommands }}
Use "{{.CommandPath}} [<command>] --help" for more information about a command.
Use "{{.CommandPath}} [command] --help" for more information about a command.
{{- end}}
`
4 changes: 2 additions & 2 deletions cmd/dagger/module.go
Expand Up @@ -78,7 +78,7 @@ func init() {
}

var moduleInitCmd = &cobra.Command{
Use: "init [flags] [<path>]",
Use: "init [flags] [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 [flags] <module>",
Use: "install [flags] [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 [flags] [<operation>]",
Use: "query [flags] [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 [flags] <command>",
Use: "run [flags] [command]",
Aliases: []string{"r"},
Short: "Run a command in a Dagger session",
Long: strings.ReplaceAll(
Expand Down
2 changes: 1 addition & 1 deletion cmd/dagger/watch.go
Expand Up @@ -10,7 +10,7 @@ import (
)

var watchCmd = &cobra.Command{
Use: "watch [flags] <command>",
Use: "watch [flags] [command]",
Hidden: true,
Annotations: map[string]string{
"experimental": "true",
Expand Down
2 changes: 1 addition & 1 deletion cmd/shim/main.go
Expand Up @@ -89,7 +89,7 @@ func main() {

func internalCommand() int {
if len(os.Args) < 2 {
fmt.Fprintf(os.Stderr, "usage: %s <command> [<args>]\n", os.Args[0])
fmt.Fprintf(os.Stderr, "usage: %s <command> [args]\n", os.Args[0])
return errorExitCode
}

Expand Down
12 changes: 6 additions & 6 deletions docs/current_docs/cli/979595-reference.mdx
Expand Up @@ -49,7 +49,7 @@ by appending it to the end of the command (for example, `stdout`, `entries`, or


```
dagger call [flags] [FUNCTION]...
dagger call [flags] [function]...
```

### Examples
Expand Down Expand Up @@ -177,7 +177,7 @@ available functions.


```
dagger functions [flags] [FUNCTION]...
dagger functions [flags] [function]...
```

### Options
Expand Down Expand Up @@ -218,7 +218,7 @@ The "--source" flag allows controlling the directory in which the actual module


```
dagger init [flags] [PATH]
dagger init [flags] [path]
```

### Examples
Expand Down Expand Up @@ -257,7 +257,7 @@ Add a new dependency to a Dagger module
Add a Dagger module as a dependency of a local module.

```
dagger install [flags] MODULE
dagger install [flags] [module]
```

### Examples
Expand Down Expand Up @@ -341,7 +341,7 @@ queries in the document.


```
dagger query [flags] [OPERATION]
dagger query [flags] [operation]
```

### Examples
Expand Down Expand Up @@ -406,7 +406,7 @@ jq -n '{query:"{container{id}}"}' | \
```
```
dagger run [flags] COMMAND
dagger run [flags] [command]
```
### Examples
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.

0 comments on commit f2bdbf3

Please sign in to comment.