-
Notifications
You must be signed in to change notification settings - Fork 362
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
Reading values passed after command option as list of strings #297
Comments
Currently, your example |
so, the second case you explained by making argument as positional argument arg[0] would point to -raw or raw? and arg[1] onwards i can treat as the input raw bytes and put them to list? |
I need some way to parse a normal command vs a raw command passed For e.g i have same application accepting another command like ./app -command [some command name] [sub command1] The same app will also have option like i told above ./app -raw/raw 0x05 0x04 0x03, etc. I hope i am clear now Thanks, |
In CLI11, long options must start with a double dash. Subcommands should have no dash. So you can do what you want to rather easily as long as you can drop the dash, that is:
Here's an example: https://wandbox.org/permlink/rMGeZwjyGxYtY9Im Change the "raw" to "command" and you'll see that it's filling in a different "remaining" vector. |
Sorry .. I messed up again I meant , I want to have two options in my app ./app --command [main command][subcommand1] - This one i have already implemented Thanks, |
Coding like this throws "Too many positional arguments with unlimited expected args error" |
I think is resolved, so I am closing it, if there is some other issue feel free to make a new one |
Hi,
I have to write an application that takes raw hex bytes as input
./app -raw 0x05 0x04 0x03 .. some thing like this
I will interpret the data got and parse it to see I have received in the proper hex format
I know that add_option() will take a vector as argument which we can access like arg[0], arg[1] which will be commands and it is number of subcommands
Is there a way I can read all the data passed after -raw option as list of strings? and treat arg[0] as the main command instead of treating them as subcommands?
Thanks in advance for the help
Thanks,
Lakshmi
The text was updated successfully, but these errors were encountered: