Closed suntong closed 8 years ago
Ok ,I will fix it.
Many thanks!
Hey. I removed NeedArgs
. Now, NumArg
added. See commit 0a75f3d and example_narg_test.go
That's super! Amazingly thorough!!
Please take a look at my
allow multiple arguments (none-option parameters) for install
I think I've done it right, but this is what I got:
$ gogo install pkg1 pkg2 pkg3
ERR! command install pkg1 pkg2 pkg3 not found
In this case, you should set CanSubRoute
true for command install
, otherwise CLI will try find the command install
->pkg1
->pkg2
->pkg3
var _ = app.Register(&cli.Command{
Name: "install",
Desc: "Install golang application",
Text: "Usage:\n gogo install [Options] package [package...]",
Argv: func() interface{} { return new(installT) },
Fn: install,
CanSubRoute: true,
NumArg: cli.AtLeast(1),
})
Thanks. Works great.
Hmm.., should CanSubRoute
true affect ctx.Path()
as well?
var _ = app.Register(&cli.Command{
Name: "install",
Desc: "Install golang application",
Text: "Usage:\n gogo install [Options] package [package...]",
Argv: func() interface{} { return new(installT) },
Fn: install,
NumArg: cli.AtLeast(1),
CanSubRoute: true,
})
...
ctx.String("%s: %v", ctx.Path(), jsonIndent(argv))
$ gogo install pkg1 pkg2 pkg3
install pkg1 pkg2 pkg3: {
^^^^^^^^^^^^^^^^^^^^^^
"Help": false,
"Dir": "./",
"Suffix": ".go,.c,.s",
"Out": ""
}
Installing: [pkg1 pkg2 pkg3]
😭,This is a bug!
hehe, glad that I can help squashing some. :)
I should write more tests.
You "should" have more people to use it. haha...
Don't worry, they will. :)
Hey 仕晋,
Does
NeedArgs
means need argument or need option?Please see my demo how to handle none-option parameters, in which I added a none-option parameters to
build
:It runs fine:
However, my code would panic if the
Arch
none-option parameter is not specified. So we need clarification here. Once again,rsync
takes an awful lot of options, but besides them, at the end of command line, there are none-option parameters, normally called argument. I hope thatNeedArgs
really means this, which goes with common understanding and all other commands.Thanks