提交 c49dd3f5 编写于 作者: J Jingwen Owen Ou 提交者: Mislav Marohnić

Exit with error if command-line flag parsing fails

上级 bd1cb2ce
......@@ -3,8 +3,9 @@ package commands
import (
"bytes"
"fmt"
flag "github.com/ogier/pflag"
"strings"
flag "github.com/ogier/pflag"
)
var (
......@@ -49,11 +50,8 @@ func (c *Command) Call(args *Args) (err error) {
func (c *Command) parseArguments(args *Args) (err error) {
c.Flag.SetInterspersed(true)
if !c.GitExtension {
c.Flag.Usage = c.PrintUsage
}
c.Flag.Init(c.Name(), flag.ContinueOnError)
c.Flag.Usage = c.PrintUsage
if err = c.Flag.Parse(args.Params); err == nil {
args.Params = c.Flag.Args()
}
......
......@@ -43,9 +43,9 @@ Feature: hub pull-request
When I successfully run `hub pull-request -m ăéñøü`
Then the output should contain exactly "the://url\n"
Scenario: Deprecated title argument can't start with a dash
When I run `hub pull-request -help`
Then the stderr should contain "invalid argument: -help\n"
Scenario: Invalid flag
When I run `hub pull-request -yelp`
Then the stderr should contain "unknown shorthand flag: 'y' in -yelp\n"
And the exit status should be 1
Scenario: Non-existing base
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册