From 3216cbc07f9eb698ae88d3214c0647650a542bb7 Mon Sep 17 00:00:00 2001 From: Jose Garcia Date: Fri, 3 Sep 2021 11:43:10 -0400 Subject: [PATCH 1/2] codespace flag, deprecate argument --- cmd/ghcs/code.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/cmd/ghcs/code.go b/cmd/ghcs/code.go index 5bad53648..ba4f0234e 100644 --- a/cmd/ghcs/code.go +++ b/cmd/ghcs/code.go @@ -7,27 +7,34 @@ import ( "os" "github.com/github/ghcs/api" + "github.com/github/ghcs/cmd/ghcs/output" "github.com/github/ghcs/internal/codespaces" "github.com/skratchdot/open-golang/open" "github.com/spf13/cobra" ) func newCodeCmd() *cobra.Command { - useInsiders := false + var ( + codespace string + useInsiders bool + ) + + log := output.NewLogger(os.Stdout, os.Stderr, false) codeCmd := &cobra.Command{ - Use: "code []", + 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 { - codespaceName = args[0] + log.Println(" argument is deprecated. Use --codespace instead.") + codespace = args[0] } - return code(codespaceName, useInsiders) + return code(codespace, useInsiders) }, } + codeCmd.Flags().StringVarP(&codespace, "codespace", "c", "", "Name of the codespace") codeCmd.Flags().BoolVar(&useInsiders, "insiders", false, "Use the insiders version of VS Code") return codeCmd From 3b198c1707737ed000febd0eb9b469452231f097 Mon Sep 17 00:00:00 2001 From: Jose Garcia Date: Thu, 9 Sep 2021 10:09:14 -0400 Subject: [PATCH 2/2] switch to Errorln --- cmd/ghcs/code.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/ghcs/code.go b/cmd/ghcs/code.go index ba4f0234e..d14a66926 100644 --- a/cmd/ghcs/code.go +++ b/cmd/ghcs/code.go @@ -27,7 +27,7 @@ func newCodeCmd() *cobra.Command { Args: cobra.MaximumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { if len(args) > 0 { - log.Println(" argument is deprecated. Use --codespace instead.") + log.Errorln(" argument is deprecated. Use --codespace instead.") codespace = args[0] } return code(codespace, useInsiders)