Is there a tool or macro processor capable of compactly expressing BASH CLI interfaces?
0
votes
0
answers
58
views
I am writing scripts with the following boilerplate CLI pattern:
usage(){
echo "$0 yada yada"
...
echo
}
for arg in "$@"; do
case "$arg" in
'--help|-help') set -- "$@" '-h';;
...
esac
done
OPTIND=1
while getopts 'h...' opt; do
case "$opt" in
'h') usage; exit 0;;
...
esac
done
shift $((OPTIND-1))
Is there any way to compress or encapsulate this in BASH on linux with other tools, perhaps an additional dependency?
Asked by Chris
(1075 rep)
Jul 25, 2023, 03:37 PM