Provide a documentation string to get named function parameters. Fork of msknapp's. Similar to docopt
Just copy the file or use package managers.
Get bpkg.
To get the source version:
bpkg install matthewdeanmartin/parse_quick_parameters.shTo get the hosted version:
bpkg install parse_quick_parametersThis is a fancy way of just downloading git files.
pip install git-remote-get
git-remote-get ./ --owner matthewdeanmartin --repo "parse_quick_parameters.sh" deps
#!/usr/bin/env bash
source deps/parse_quick_parameters/parse_quick_parameters.sh
function do_something_quick {
parse_quick_parameters "my_file=-f|--file,bool:run=-r|--run,name=-n|--name" "$@" || return 0
echo "my file is: $my_file"
echo "my name is: $name"
echo "run is: $run"
}>> source parse_quick_parameters.sh
>> do_something_quick --name name --run --file file
my file is: file
my name is: name
run is: true
>> do_something_quick "file" "name" --run
my file is: file
my name is: name
run is: true
Shellcheck doesn't understand the pattern and will raise SC2154
- getopts Builtin bash command
- docopts Shell version of
docopts - argparse-bash Use python's argparse in bash
Use Makefile. bats tests assume bats was installed with npm.
make format lint test