Skip to content

Instantly share code, notes, and snippets.

@webb
webb / simple-cli-parser.bash
Created October 2, 2020 15:18
A simple CLI parser in Bash
#!/usr/bin/env bash
print_help () { echo "Option -f \${file}: Set file"; exit 0; }
fail () { echo "Error: $*" >&2; exit 1; }
unset file
OPTIND=1
while getopts :f:h-: option
do case $option in
h ) print_help;;