I want to have params like this:
program dothis --additional --options
and:
program dothat --with_this_option=value
and I can't get how to do that. The only thing I managed to do is to use params with -- at the beginning.
Any ideas?
I want to have params like this:
program dothis --additional --options
and:
program dothat --with_this_option=value
and I can't get how to do that. The only thing I managed to do is to use params with -- at the beginning.
Any ideas?
Copyright © 2021 Jogjafile Inc.
To handle positional parameters using OptionParser, first parse the switches using OptionParser and then fetch the remaining positional arguments from ARGV:
On executing the script:
The
dothisordothatcommands can be anywhere. Theoptionshash andARGVremains the same regardless: