From c82d4c54724d9d879350052d7f0c993d92ec13c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Fri, 24 Sep 2021 17:36:18 +0200 Subject: [PATCH] Avoid passing params struct as pointer --- cmd/ghcs/create.go | 4 ++-- cmd/ghcs/list.go | 14 +++++--------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/cmd/ghcs/create.go b/cmd/ghcs/create.go index 7e861e08d..7174e7721 100644 --- a/cmd/ghcs/create.go +++ b/cmd/ghcs/create.go @@ -23,7 +23,7 @@ type createOptions struct { } func newCreateCmd(app *App) *cobra.Command { - opts := &createOptions{} + opts := createOptions{} createCmd := &cobra.Command{ Use: "create", @@ -43,7 +43,7 @@ func newCreateCmd(app *App) *cobra.Command { } // Create creates a new Codespace -func (a *App) Create(ctx context.Context, opts *createOptions) error { +func (a *App) Create(ctx context.Context, opts createOptions) error { locationCh := getLocation(ctx, a.apiClient) userCh := getUser(ctx, a.apiClient) diff --git a/cmd/ghcs/list.go b/cmd/ghcs/list.go index 842b9313d..1fc59cff0 100644 --- a/cmd/ghcs/list.go +++ b/cmd/ghcs/list.go @@ -10,28 +10,24 @@ import ( "github.com/spf13/cobra" ) -type listOptions struct { - asJSON bool -} - func newListCmd(app *App) *cobra.Command { - opts := &listOptions{} + var asJSON bool listCmd := &cobra.Command{ Use: "list", Short: "List your codespaces", Args: noArgsConstraint, RunE: func(cmd *cobra.Command, args []string) error { - return app.List(cmd.Context(), opts) + return app.List(cmd.Context(), asJSON) }, } - listCmd.Flags().BoolVar(&opts.asJSON, "json", false, "Output as JSON") + listCmd.Flags().BoolVar(&asJSON, "json", false, "Output as JSON") return listCmd } -func (a *App) List(ctx context.Context, opts *listOptions) error { +func (a *App) List(ctx context.Context, asJSON bool) error { user, err := a.apiClient.GetUser(ctx) if err != nil { return fmt.Errorf("error getting user: %w", err) @@ -42,7 +38,7 @@ func (a *App) List(ctx context.Context, opts *listOptions) error { return fmt.Errorf("error getting codespaces: %w", err) } - table := output.NewTable(os.Stdout, opts.asJSON) + table := output.NewTable(os.Stdout, asJSON) table.SetHeader([]string{"Name", "Repository", "Branch", "State", "Created At"}) for _, codespace := range codespaces { table.Append([]string{