I'm trying to port old command line tool to boost::program_options. The tool is used in lots of 3rd-party scripts, some of them I cannot update, so changing of command line interface (CLI) is not the way for me.
I have one positional argument, several flag and regular arguments. But I run into a trouble with ranges argument. It should work as follows:
> my_too.exe -ranges 1,2,4-7,4 some_file.txt # args[ranges]="1,2,4-7,4"
> my_too.exe -ranges -other_param some_file.txt # args[ranges]=""
> my_too.exe -ranges some_file.txt # args[ranges]=""
Basically, I want boost::po to stop parsing argument value if other argument is met or if type doesn't match. Is there a way to implement exactly this behavior?
I tried using implicit_value but it doesn't work because it will require CLI format change (argument is required to be adjusted with a key):
> my_too.exe -ranges="1,2-3,7" some_file.txt
I tried using multitoken, zero_tokens trick, but it doesn't stop when positional argument is met or argument doesn't match.
> my_tool.exe -ranges 1,2-4,7 some_file.txt # args[ranges]=1,2-4,7,some_file.txt
Any ideas?