cli.go: in CliParser.Parse() renamed args as commandArgs
This commit is contained in:
parent
95fae40d5f
commit
92267aec50
10
cli.go
10
cli.go
@ -161,7 +161,7 @@ func (cli *CliParser) addHelpAndVersion() {
|
||||
func (cli *CliParser) Parse() (err error) {
|
||||
var arg string
|
||||
var i int
|
||||
var args []string
|
||||
var commandArgs []string
|
||||
var optionsAllowed bool = true
|
||||
|
||||
cli.addHelpAndVersion()
|
||||
@ -182,7 +182,7 @@ func (cli *CliParser) Parse() (err error) {
|
||||
break
|
||||
}
|
||||
} else {
|
||||
args = append(args, arg)
|
||||
commandArgs = append(commandArgs, arg)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -196,18 +196,18 @@ func (cli *CliParser) Parse() (err error) {
|
||||
specIndex := -1
|
||||
for index, argSpec := range cli.argSpecs {
|
||||
specIndex = index
|
||||
if n, err = argSpec.parse(cli, specIndex, args, i); err != nil {
|
||||
if n, err = argSpec.parse(cli, specIndex, commandArgs, i); err != nil {
|
||||
break
|
||||
}
|
||||
i += n
|
||||
if i >= len(args) {
|
||||
if i >= len(commandArgs) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// check if there are remaining arg-specs that require a value
|
||||
if err == nil {
|
||||
if i < len(args) {
|
||||
if i < len(commandArgs) {
|
||||
err = fmt.Errorf("too many arguments: %d allowed", i)
|
||||
} else {
|
||||
specIndex++
|
||||
|
||||
Loading…
Reference in New Issue
Block a user