Skip to content

matthewdeanmartin/parse_quick_parameters.sh

Repository files navigation

parse_quick_parameters.sh

Provide a documentation string to get named function parameters. Fork of msknapp's. Similar to docopt

Installation

Just copy the file or use package managers.

Use bkpg

Get bpkg.

To get the source version:

bpkg install matthewdeanmartin/parse_quick_parameters.sh

To get the hosted version:

bpkg install parse_quick_parameters

Use git-remote-get

This 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

Usage

#!/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

Notes

Shellcheck doesn't understand the pattern and will raise SC2154

Alternatives

Contributing

Use Makefile. bats tests assume bats was installed with npm.

make format lint test

Credits

About

Provide a documentation string to get named function parameters. Fork of msknapp's. Similar to docopt

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published