Unverified Commit fc6b67b2 authored by Mustaque Ahmed's avatar Mustaque Ahmed Committed by GitHub
Browse files

fix: show usage message with unrecognized flag (#255)

Co-authored-by: default avatarDima Brusilovsky <dimabru@gmail.com>
parent 84b457f7
No related merge requests found
Showing with 4 additions and 6 deletions
+4 -6
......@@ -42,12 +42,13 @@ func New(ctx *PublishCommandContext) *cobra.Command {
Args: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
errMessage := "Requires 1 arg\n"
cmd.Usage()
return fmt.Errorf(errMessage)
}
return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
cmd.SilenceUsage = true
cmd.SilenceErrors = true
messages := make(chan *messager.VersionMessage, 1)
go ctx.Messager.LoadVersionMessages(messages, ctx.CliVersion)
defer func() {
......@@ -71,8 +72,6 @@ func New(ctx *PublishCommandContext) *cobra.Command {
return err
},
SilenceUsage: true,
SilenceErrors: true,
}
return publishCommand
......
......@@ -81,12 +81,13 @@ func New(ctx *TestCommandContext) *cobra.Command {
Args: func(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
errMessage := "Requires at least 1 arg\n"
cmd.Usage()
return fmt.Errorf(errMessage)
}
return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
cmd.SilenceUsage = true
cmd.SilenceErrors = true
var err error = nil
defer func() {
if err != nil {
......@@ -132,8 +133,6 @@ func New(ctx *TestCommandContext) *cobra.Command {
}
return nil
},
SilenceUsage: true,
SilenceErrors: true,
}
testCommand.Flags().StringP("output", "o", "", "Define output format")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment