Skip to content
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

get full original command line (full argv[]) within a command function #66

Open
andrewhlin opened this issue Sep 28, 2018 · 1 comment

Comments

@andrewhlin
Copy link

Is there currently an easy way to pull out the full original command line string that was used to invoke the program (essentially what argv was) from within a Command/subparser with the current API? I use the commands interface, and have a separate function that is invoked for subcommands. Within a subcommand, I want to be able to get the full command line to be able to print it out to a log file that gets created based on the input args to the program. Is there a way to do this right now that I'm just missing?

@ghost
Copy link

ghost commented Sep 28, 2018

You can capture argc and argv in lambda and pass them to your function:

Command command(..., [=](Subparser& p) { MyCommand(p, argc, argv); });

Or use std::bind:

Command command(..., std::bind(MyCommand, _1, argc, argv));

There is no other way to do it with current API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant