improve error message

This commit is contained in:
Alisson Santos 2020-11-03 18:46:07 +01:00
parent d79eb494d9
commit 7a106e2ded
2 changed files with 9 additions and 2 deletions

View file

@ -2,6 +2,7 @@ package create
import (
"bytes"
"errors"
"fmt"
"io/ioutil"
"net/http"
@ -76,7 +77,13 @@ func NewCmdCreate(f *cmdutil.Factory, runF func(*CreateOptions) error) *cobra.Co
# upload a release asset with a display label
$ gh release create v1.2.3 '/path/to/asset.zip#My display label'
`),
Args: cobra.MinimumNArgs(1),
Args: func(cmd *cobra.Command, args []string) error {
if len(args) > 0 {
return nil
}
return &cmdutil.FlagError{Err: errors.New("could not create: no tag name provided")}
},
RunE: func(cmd *cobra.Command, args []string) error {
// support `-R, --repo` override
opts.BaseRepo = f.BaseRepo

View file

@ -158,7 +158,7 @@ func Test_NewCmdCreate(t *testing.T) {
name: "no arguments",
args: "",
isTTY: true,
wantErr: "requires at least 1 arg(s), only received 0",
wantErr: "could not create: no tag name provided",
},
}
for _, tt := range tests {