Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
37 lines (25 sloc) 573 Bytes

bash port of substack/optimist

#source into your bash script

source the output back into this script. it will create env vars with the prefix argv_

optionally set a different prefix . <(PREFIX=whatever_ argv "$@")

. <(argv "$@") 

# iterate over them like this:

for key in ${!argv_*}; do
  echo "$key"="$value"

supports a bunch of arguments styles!

./ arg1 --key1 value1 --key2=value2 --no-falsey --truthy -t -f -- arg2 arg3