cli
cli copied to clipboard
SkipFlagParsing is not working if there are Subcommands
my urfave/cli version is
v1.22.5
Checklist
- [x] Are you running the latest v1 release? The list of releases is here.
- [x] Did you check the manual for your release? The v1 manual is here
- [x] Did you perform a search about this problem? Here's the Github guide about searching.
Dependency Management
- My project is using go modules.
Describe the bug
The options of SkipFlagParsing: true
and CustomHelpTemplate:"..."
are not working if there are Subcommands.
To reproduce
package main
import (
"fmt"
"os"
"github.com/urfave/cli"
)
func main() {
app := cli.NewApp()
app.Name = "foo"
app.Commands = []cli.Command{
{
Name: "bar",
SkipFlagParsing: true,
Action: func(c *cli.Context) {
fmt.Println(c.Args())
},
Subcommands: []cli.Command{{
Name: "barfoo",
SkipFlagParsing: true,
Action: func(c *cli.Context) {
fmt.Println(c.Args())
},
},
},
},
}
app.Run(os.Args)
}
Observed behavior
Run:
go build -o skip && ./skip bar --a
Observed behavior:
Incorrect Usage. flag provided but not defined: -a
NAME:
foo bar -
USAGE:
foo bar command [command options] [arguments...]
COMMANDS:
barfoo
OPTIONS:
--help, -h show help
Expected behavior
The output should be:
[--a]
Additional context
It works if I remove:
Subcommands: []cli.Command{{
Name: "barfoo",
SkipFlagParsing: true,
Action: func(c *cli.Context) {
fmt.Println(c.Args())
},
},
},
@meatballhat I can take a look at this
@dearchap thank you much!
@meatballhat Are we still fixing v1 issues ? I verified that this issue doesnt exist in v2.
@dearchap I'd love to know 😅 I asked a question a few days ago in @urfave/maintainers discussions but I've re-posted now in @urfave/cli discussions. If having this conversation in a public issue is acceptable, I'll gladly go that route instead.
@Or-Geva By definition you should not use subcommands when you set skip flag parsing