Skip to content

Commit

Permalink
Merge 06bb5cd into 7061ca3
Browse files Browse the repository at this point in the history
  • Loading branch information
alanxoc3 committed Jun 27, 2020
2 parents 7061ca3 + 06bb5cd commit 3d0f393
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ language: go
sudo: false
go:
- "1.x"

before_install:
- go get github.com/mattn/goveralls

script:
- go test -v .
- go test -v ./...
- $GOPATH/bin/goveralls -service=travis-ci
10 changes: 8 additions & 2 deletions argparse.go
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ func (o *Command) Usage(msg interface{}) string {
// was active when error happened and print that specific Command usage).
// In case no error returned all arguments should be safe to use. Safety of using arguments
// before Parse operation is complete is not guaranteed.
func (o *Parser) Parse(args []string) error {
func (o *Parser) ParseReturnArguments(args []string) ([]string, error) {
subargs := make([]string, len(args))
copy(subargs, args)

Expand All @@ -658,9 +658,15 @@ func (o *Parser) Parse(args []string) error {
unparsed = append(unparsed, v)
}
}

return unparsed, result
}

func (o *Parser) Parse(args []string) error {
unparsed, result := o.ParseReturnArguments(args)

if result == nil && len(unparsed) > 0 {
return errors.New("unknown arguments " + strings.Join(unparsed, " "))
}

return result
}
5 changes: 5 additions & 0 deletions argument.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type Arg interface {
GetOpts() *Options
GetSname() string
GetLname() string
IsFlag() bool
}

func (o arg) GetOpts() *Options {
Expand All @@ -42,6 +43,10 @@ func (o arg) GetLname() string {
return o.lname
}

func (o arg) IsFlag() bool {
return o.size == 1
}

type help struct{}

// checkLongName if long argumet present.
Expand Down

0 comments on commit 3d0f393

Please sign in to comment.