diff --git a/cmd/ghcs/code.go b/cmd/ghcs/code.go index ccb4788ee..23dc0f767 100644 --- a/cmd/ghcs/code.go +++ b/cmd/ghcs/code.go @@ -14,8 +14,9 @@ import ( func NewCodeCmd() *cobra.Command { return &cobra.Command{ - Use: "code", - Short: "Open a GitHub Codespace in VSCode.", + Use: "code []", + Short: "Open a Codespace in VS Code", + Args: cobra.MaximumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { var codespaceName string if len(args) > 0 { diff --git a/cmd/ghcs/create.go b/cmd/ghcs/create.go index 385e5d957..2228bc105 100644 --- a/cmd/ghcs/create.go +++ b/cmd/ghcs/create.go @@ -17,7 +17,8 @@ var repo, branch, machine string func newCreateCmd() *cobra.Command { createCmd := &cobra.Command{ Use: "create", - Short: "Create a GitHub Codespace.", + Short: "Create a Codespace", + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { return Create() }, diff --git a/cmd/ghcs/delete.go b/cmd/ghcs/delete.go index f374ef7e6..c3a842e4f 100644 --- a/cmd/ghcs/delete.go +++ b/cmd/ghcs/delete.go @@ -2,7 +2,6 @@ package main import ( "context" - "errors" "fmt" "os" @@ -13,8 +12,9 @@ import ( func NewDeleteCmd() *cobra.Command { deleteCmd := &cobra.Command{ - Use: "delete", - Short: "Delete a GitHub Codespace.", + Use: "delete []", + Short: "Delete a Codespace", + Args: cobra.MaximumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { var codespaceName string if len(args) > 0 { @@ -26,22 +26,18 @@ func NewDeleteCmd() *cobra.Command { deleteAllCmd := &cobra.Command{ Use: "all", - Short: "delete all codespaces", - Long: "delete all codespaces for the user with the current token", + Short: "Delete all Codespaces for the current user", + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { return DeleteAll() }, } deleteByRepoCmd := &cobra.Command{ - Use: "repo REPO_NAME", - Short: "delete all codespaces for the repo", - Long: `delete all the codespaces that the user with the current token has in this repo. -This includes all codespaces in all states.`, + Use: "repo ", + Short: "Delete all Codespaces for a repository", + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - if len(args) == 0 { - return errors.New("A Repository name is required.") - } return DeleteByRepo(args[0]) }, } diff --git a/cmd/ghcs/list.go b/cmd/ghcs/list.go index 6db79af97..f19095ff8 100644 --- a/cmd/ghcs/list.go +++ b/cmd/ghcs/list.go @@ -14,7 +14,8 @@ import ( func NewListCmd() *cobra.Command { listCmd := &cobra.Command{ Use: "list", - Short: "List GitHub Codespaces you have on your account.", + Short: "List your Codespaces", + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { return List() }, diff --git a/cmd/ghcs/logs.go b/cmd/ghcs/logs.go index 03a7c963a..3c192b081 100644 --- a/cmd/ghcs/logs.go +++ b/cmd/ghcs/logs.go @@ -15,8 +15,9 @@ func NewLogsCmd() *cobra.Command { var tail bool logsCmd := &cobra.Command{ - Use: "logs", + Use: "logs []", Short: "Access Codespace logs", + Args: cobra.MaximumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { var codespaceName string if len(args) > 0 { diff --git a/cmd/ghcs/ports.go b/cmd/ghcs/ports.go index 77d1b00f7..2e0e44908 100644 --- a/cmd/ghcs/ports.go +++ b/cmd/ghcs/ports.go @@ -20,7 +20,8 @@ import ( func NewPortsCmd() *cobra.Command { portsCmd := &cobra.Command{ Use: "ports", - Short: "Forward ports from a GitHub Codespace.", + Short: "List ports in a Codespace", + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { return Ports() }, @@ -167,14 +168,10 @@ func getDevContainer(ctx context.Context, apiClient *api.API, codespace *api.Cod func NewPortsPublicCmd() *cobra.Command { return &cobra.Command{ - Use: "public", - Short: "public", - Long: "public", + Use: "public ", + Short: "Mark port as public", + Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { - if len(args) < 2 { - return errors.New("[codespace_name] [source] port number are required.") - } - return updatePortVisibility(args[0], args[1], true) }, } @@ -182,14 +179,10 @@ func NewPortsPublicCmd() *cobra.Command { func NewPortsPrivateCmd() *cobra.Command { return &cobra.Command{ - Use: "private", - Short: "private", - Long: "private", + Use: "private ", + Short: "Mark port as private", + Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { - if len(args) < 2 { - return errors.New("[codespace_name] [source] port number are required.") - } - return updatePortVisibility(args[0], args[1], false) }, } @@ -245,13 +238,10 @@ func updatePortVisibility(codespaceName, sourcePort string, public bool) error { func NewPortsForwardCmd() *cobra.Command { return &cobra.Command{ - Use: "forward", - Short: "forward", - Long: "forward", + Use: "forward ", + Short: "Forward port", + Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) error { - if len(args) < 3 { - return errors.New("[codespace_name] [source] [dst] port number are required.") - } return forwardPort(args[0], args[1], args[2]) }, } diff --git a/cmd/ghcs/ssh.go b/cmd/ghcs/ssh.go index 60fdee498..428cd74bf 100644 --- a/cmd/ghcs/ssh.go +++ b/cmd/ghcs/ssh.go @@ -20,14 +20,15 @@ func NewSSHCmd() *cobra.Command { sshCmd := &cobra.Command{ Use: "ssh", - Short: "SSH into a GitHub Codespace, for use with running tests/editing in vim, etc.", + Short: "SSH into a Codespace", + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { return SSH(sshProfile, codespaceName, sshServerPort) }, } - sshCmd.Flags().StringVarP(&sshProfile, "profile", "", "", "SSH Profile") - sshCmd.Flags().IntVarP(&sshServerPort, "server-port", "", 0, "SSH Server Port") + sshCmd.Flags().StringVarP(&sshProfile, "profile", "", "", "The `name` of the SSH profile to use") + sshCmd.Flags().IntVarP(&sshServerPort, "server-port", "", 0, "SSH server port number") sshCmd.Flags().StringVarP(&codespaceName, "codespace", "c", "", "Codespace Name") return sshCmd