in reply to Getopt::Long via. Hashes
I had similar question, so I re-invented the wheel and wrote my own GetOpts wrapper
app code library code tests more tests(you can use it if you want to and capable to understand how it works, it's GPLv3. or maybe some day i'll release it on CPAN with product quality and documentation)
Basically I verify options and option combination using plain 'if/else' code, but in separate 'layer' (before program execution), so when program start main work it has already all options validated and possibly reorganized.
And I have DSL to for easier validation layer implementation for easier options definitions
Also the library manages error/warning messages and helps to write unit test for options behaviour with ease
Also you can try to reorganize your command line API and discinct options, commands, positional parameters, and script name aliases. That way complex options will look more sane
Example:
instead ofmyapp-recaulculate.pl full-recalculate myfile --fast --ignore-errors
Also, I believe there is more than 100 CPAN modules, related to options processing. You can try to find one that fits your need.myapp.pl --reculculate --use-full-recalculate --file myfile --fast --i +gnore-errors.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Getopt::Long via. Hashes
by librarat (Novice) on May 26, 2013 at 19:11 UTC | |
by vsespb (Chaplain) on May 26, 2013 at 19:19 UTC |