hledger/shell-completion/output-options.sh

18 lines
408 B
Bash
Raw Normal View History

2019-01-10 21:08:46 +03:00
#!/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-Z][-_a-zA-Z0-9]*)=?.*/\1/gp' < "$tmp"
2019-01-10 21:08:46 +03:00
}
main "$@"