4 ms·
You can use bash-modules arguments library to generate argument parser for you.
by drran 5y ago
You can use bash-modules arguments library to generate argument parser for you.
- MereInterest 5y agoThank you, I haven't heard of that one before. However, all the examples look like it gets called as an external library, which would either need to be distributed with a script, or to already be installed by a user. Is there a feature I'm not seeing that would generate an argument parser without external dependencies?
- drran 5y agoYes, arguments::generate_parser function. Install bash-modules, then run `. import.sh log arguments`, then call `arguments::generate_parser '--foo)FOO;String'` , and it will generate function with parser, which include parser for foo option for both `--foo VALUE` and `--foo=VALUE`: ... --foo) FOO="${2:?ERROR: String value is required for \"-f|--foo\" option. See --help for details.}" shift 2 ;; --foo=*) FOO="${1#*=}" shift 1 ;; ...