X Tutup
Skip to content

Commit 55c717d

Browse files
committed
Print friendly error when 'gh gist <command>' is missing required argument
1 parent 230441e commit 55c717d

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

pkg/cmd/gist/delete/delete.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ package delete
22

33
import (
44
"fmt"
5+
"net/http"
6+
"strings"
7+
58
"github.com/cli/cli/api"
69
"github.com/cli/cli/internal/ghinstance"
710
"github.com/cli/cli/pkg/cmd/gist/shared"
811
"github.com/cli/cli/pkg/cmdutil"
912
"github.com/cli/cli/pkg/iostreams"
1013
"github.com/spf13/cobra"
11-
"net/http"
12-
"strings"
1314
)
1415

1516
type DeleteOptions struct {
@@ -28,7 +29,7 @@ func NewCmdDelete(f *cmdutil.Factory, runF func(*DeleteOptions) error) *cobra.Co
2829
cmd := &cobra.Command{
2930
Use: "delete {<gist ID> | <gist URL>}",
3031
Short: "Delete a gist",
31-
Args: cobra.ExactArgs(1),
32+
Args: cmdutil.MinimumArgs(1, "cannot delete: gist argument required"),
3233
RunE: func(c *cobra.Command, args []string) error {
3334
opts.Selector = args[0]
3435
if runF != nil {

pkg/cmd/gist/edit/edit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func NewCmdEdit(f *cmdutil.Factory, runF func(*EditOptions) error) *cobra.Comman
4949
cmd := &cobra.Command{
5050
Use: "edit {<gist ID> | <gist URL>}",
5151
Short: "Edit one of your gists",
52-
Args: cobra.ExactArgs(1),
52+
Args: cmdutil.MinimumArgs(1, "cannot edit: gist argument required"),
5353
RunE: func(c *cobra.Command, args []string) error {
5454
opts.Selector = args[0]
5555

pkg/cmd/gist/view/view.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func NewCmdView(f *cmdutil.Factory, runF func(*ViewOptions) error) *cobra.Comman
3434
cmd := &cobra.Command{
3535
Use: "view {<gist id> | <gist url>}",
3636
Short: "View a gist",
37-
Args: cobra.ExactArgs(1),
37+
Args: cmdutil.MinimumArgs(1, "cannot view: gist argument required"),
3838
RunE: func(cmd *cobra.Command, args []string) error {
3939
opts.Selector = args[0]
4040

0 commit comments

Comments
 (0)
X Tutup