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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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: