A command-line argument parser written in pure Bash, for size-constrained systems, such as Android devices running Termux, Windows as a secondary OS using the Subsystem for Linux or minimal Docker containers.
It implements a subset of the docopt language, which should be enough for most scripting needs.
Given the documentation below...
Ship helpers
Usage:
ship [options] move <x> <y>
ship [fast] create
ship paint (green|red)
Options:
-f --force Ignore ongoing movement
-t --target <target> Ship-id [default: 0]
...the following script calls are valid and will set the variables accordingly:
ship move 10 30
ship create
ship fast create
ship paint red
ship -ft=2 10 30
ship -f --target 2 10 30
Real-world examples can be found in my dotfiles.
./docoptsh -h "Script description\nUsage: ..." : move -t=2 10 30
As of now, most nested structures won't work, such as:
ship [--shape <shape>]
ship (fast|[<style>])
Also, variadic arguments won't work as well:
ship destroy -- <ids>...
If the system running the script has Python installed, such as a batteries included, personal computer, you probably want to use the Python-based docopt parser.
Otherwise, if compiling and using a binary for a given OS and processor architecture isn't a concern, you can use the Go-based docopt parser.