hledger/shell-completion/output-options.sh
2019-01-23 16:46:17 -08:00

18 lines
399 B
Bash
Executable File

#!/bin/bash
# Output short and long options from man/usage text
set -o errexit -o pipefail -o nounset
main() {
declare tmp
tmp=$(mktemp)
cat > "$tmp"
sed -rn 's/.* (-[a-zA-Z0-9]).*/\1/gp' < "$tmp"
# Do not print '=' after long options with arg because it makes completion
# for option arguments harder.
sed -rn 's/.* (--[-a-zA-Z0-9]+)=?.*/\1/gp' < "$tmp"
}
main "$@"