From 87c59f2ad6e94154bc8b4cee7fe9e35b1c5d8f99 Mon Sep 17 00:00:00 2001 From: Lennart Jern Date: Tue, 10 Dec 2024 10:27:42 +0200 Subject: [PATCH] Add positional arguments to CLI usage Positional arguments like the machine name or provider name are undocumented in the CLI. This commit adds them to the "Use" string so that they show up with the --help flag. --- cmd/machine/create.go | 4 ++-- cmd/machine/delete.go | 2 +- cmd/machine/ssh.go | 2 +- cmd/machine/start.go | 2 +- cmd/machine/status.go | 2 +- cmd/machine/stop.go | 2 +- cmd/provider/add.go | 2 +- cmd/provider/delete.go | 2 +- cmd/provider/update.go | 2 +- cmd/provider/use.go | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cmd/machine/create.go b/cmd/machine/create.go index 562f4d4a0..2aa42b12d 100644 --- a/cmd/machine/create.go +++ b/cmd/machine/create.go @@ -18,13 +18,13 @@ type CreateCmd struct { ProviderOptions []string } -// NewCreateCmd creates a new destroy command +// NewCreateCmd creates a new create command func NewCreateCmd(flags *flags.GlobalFlags) *cobra.Command { cmd := &CreateCmd{ GlobalFlags: flags, } createCmd := &cobra.Command{ - Use: "create", + Use: "create [name]", Short: "Creates a new machine", RunE: func(_ *cobra.Command, args []string) error { return cmd.Run(context.Background(), args) diff --git a/cmd/machine/delete.go b/cmd/machine/delete.go index 5e40a6c9f..e44b04e5c 100644 --- a/cmd/machine/delete.go +++ b/cmd/machine/delete.go @@ -26,7 +26,7 @@ func NewDeleteCmd(flags *flags.GlobalFlags) *cobra.Command { GlobalFlags: flags, } deleteCmd := &cobra.Command{ - Use: "delete", + Use: "delete [name]", Short: "Deletes an existing machine", RunE: func(_ *cobra.Command, args []string) error { return cmd.Run(context.Background(), args) diff --git a/cmd/machine/ssh.go b/cmd/machine/ssh.go index cdccc7040..b64f31290 100644 --- a/cmd/machine/ssh.go +++ b/cmd/machine/ssh.go @@ -36,7 +36,7 @@ func NewSSHCmd(flags *flags.GlobalFlags) *cobra.Command { GlobalFlags: flags, } sshCmd := &cobra.Command{ - Use: "ssh", + Use: "ssh [name]", Short: "SSH into the machine", RunE: func(c *cobra.Command, args []string) error { return cmd.Run(context.Background(), args) diff --git a/cmd/machine/start.go b/cmd/machine/start.go index 8ea7f25c9..e089e2c3e 100644 --- a/cmd/machine/start.go +++ b/cmd/machine/start.go @@ -22,7 +22,7 @@ func NewStartCmd(flags *flags.GlobalFlags) *cobra.Command { GlobalFlags: flags, } startCmd := &cobra.Command{ - Use: "start", + Use: "start [name]", Short: "Starts an existing machine", RunE: func(_ *cobra.Command, args []string) error { return cmd.Run(context.Background(), args) diff --git a/cmd/machine/status.go b/cmd/machine/status.go index db924642e..882756f31 100644 --- a/cmd/machine/status.go +++ b/cmd/machine/status.go @@ -26,7 +26,7 @@ func NewStatusCmd(flags *flags.GlobalFlags) *cobra.Command { GlobalFlags: flags, } statusCmd := &cobra.Command{ - Use: "status", + Use: "status [name]", Short: "Retrieves the status of an existing machine", RunE: func(_ *cobra.Command, args []string) error { return cmd.Run(context.Background(), args) diff --git a/cmd/machine/stop.go b/cmd/machine/stop.go index 2f081b61f..e361cecc3 100644 --- a/cmd/machine/stop.go +++ b/cmd/machine/stop.go @@ -22,7 +22,7 @@ func NewStopCmd(flags *flags.GlobalFlags) *cobra.Command { GlobalFlags: flags, } stopCmd := &cobra.Command{ - Use: "stop", + Use: "stop [name]", Short: "Stops an existing machine", RunE: func(_ *cobra.Command, args []string) error { return cmd.Run(context.Background(), args) diff --git a/cmd/provider/add.go b/cmd/provider/add.go index 4e9645ded..d2635b268 100644 --- a/cmd/provider/add.go +++ b/cmd/provider/add.go @@ -33,7 +33,7 @@ func NewAddCmd(flags *flags.GlobalFlags) *cobra.Command { GlobalFlags: flags, } addCmd := &cobra.Command{ - Use: "add", + Use: "add [URL or path]", Short: "Adds a new provider to DevPod", PreRunE: func(cobraCommand *cobra.Command, args []string) error { if cmd.FromExisting != "" { diff --git a/cmd/provider/delete.go b/cmd/provider/delete.go index 254f21a33..8744fdea0 100644 --- a/cmd/provider/delete.go +++ b/cmd/provider/delete.go @@ -29,7 +29,7 @@ func NewDeleteCmd(flags *flags.GlobalFlags) *cobra.Command { GlobalFlags: flags, } deleteCmd := &cobra.Command{ - Use: "delete", + Use: "delete [name]", Short: "Delete a provider", RunE: func(_ *cobra.Command, args []string) error { return cmd.Run(context.Background(), args) diff --git a/cmd/provider/update.go b/cmd/provider/update.go index 940986fda..c1e1cb3d6 100644 --- a/cmd/provider/update.go +++ b/cmd/provider/update.go @@ -26,7 +26,7 @@ func NewUpdateCmd(flags *flags.GlobalFlags) *cobra.Command { GlobalFlags: flags, } updateCmd := &cobra.Command{ - Use: "update", + Use: "update [name] [URL or path]", Short: "Updates a provider in DevPod", RunE: func(_ *cobra.Command, args []string) error { ctx := context.Background() diff --git a/cmd/provider/use.go b/cmd/provider/use.go index 5625bc8b4..53f4aa873 100644 --- a/cmd/provider/use.go +++ b/cmd/provider/use.go @@ -35,7 +35,7 @@ func NewUseCmd(flags *flags.GlobalFlags) *cobra.Command { GlobalFlags: *flags, } useCmd := &cobra.Command{ - Use: "use", + Use: "use [name]", Short: "Configure an existing provider and set as default", RunE: func(_ *cobra.Command, args []string) error { if len(args) != 1 {