From 7673622830445ca8497ba4036cc9263095b02ab1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Tue, 28 Sep 2021 16:58:29 +0200 Subject: [PATCH] Mount `gh codespace` command --- go.mod | 1 + pkg/cmd/root/root.go | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/go.mod b/go.mod index 314833484..34891961e 100644 --- a/go.mod +++ b/go.mod @@ -45,3 +45,4 @@ require ( ) replace github.com/shurcooL/graphql => github.com/cli/shurcooL-graphql v0.0.0-20200707151639-0f7232a2bf7e +replace golang.org/x/crypto => ./internal/crypto diff --git a/pkg/cmd/root/root.go b/pkg/cmd/root/root.go index f24c29211..884245bcb 100644 --- a/pkg/cmd/root/root.go +++ b/pkg/cmd/root/root.go @@ -2,8 +2,12 @@ package root import ( "net/http" + "os" "github.com/MakeNowJust/heredoc" + "github.com/cli/cli/v2/cmd/ghcs" + "github.com/cli/cli/v2/cmd/ghcs/output" + ghcsApi "github.com/cli/cli/v2/internal/api" actionsCmd "github.com/cli/cli/v2/pkg/cmd/actions" aliasCmd "github.com/cli/cli/v2/pkg/cmd/alias" apiCmd "github.com/cli/cli/v2/pkg/cmd/api" @@ -105,6 +109,15 @@ func NewCmdRoot(f *cmdutil.Factory, version, buildDate string) *cobra.Command { referenceCmd.SetHelpFunc(referenceHelpFn(f.IOStreams)) cmd.AddCommand(referenceCmd) + ghcsApp := ghcs.NewApp( + output.NewLogger(f.IOStreams.Out, f.IOStreams.ErrOut, !f.IOStreams.IsStdoutTTY()), + ghcsApi.New(os.Getenv("GITHUB_TOKEN"), http.DefaultClient), + ) + ghcsCmd := ghcs.NewRootCmd(ghcsApp) + ghcsCmd.Use = "codespace" + ghcsCmd.Aliases = []string{"cs"} + cmd.AddCommand(ghcsCmd) + cmdutil.DisableAuthCheck(cmd) // this needs to appear last: