-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Different Args in "Action" and "Before" functions #92
Comments
It seems it is more inconsistent than that. If "Before" is nil, "Action" does not have its name at index 0.
|
Confirmed, setting the "Before" function disables argument parsing of my defined flags. I removed Before functions completely. |
This is definitely a bug. Thanks for the report |
This bug is due to these lines (#L211): // Run default Action
if len(a.Commands) > 0 {
a.Action(context)
} else {
a.Action(ctx)
} @codegangsta, I think we should remove this EDIT: There is already a discussion about this issue in the responsible commit. |
…ubcommands, display the CommandHelp instead of the SubcommandHelp
Addressed by #170 |
Great, just found this bug as well and can confirm it. My research also found the lines above by ghigt. The Ctx context haven't yet parsed the flags for the subcommand, but context context has and that one is used by the Before action, which makes it look like it works for Before, but not Action of the subcommand. Any ETA when a fix can be merged to master? |
@rawn merged in today, let me know if your issue persists. |
@jszwedko Works beautifully! |
I recently came across a problem when accessing Args from Context. I expected to get the same args in "Action" and "Before" functions, but "Action" has it's name at index 0 and arguments start from index 1, in "Before" arguments start from index 0.
An example to demonstrate: http://play.golang.org/p/CIrOdw3noq
Also looking at the examples https://github.com/codegangsta/cli#subcommands
I'd expect
c.Args().First()
to contain the first argument, not the command name itself. Is this desired behaviour, please?The text was updated successfully, but these errors were encountered: