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

21 lines
387 B
Bash
Executable File

#!/bin/bash
# Output subcommands from man/usage text
set -o errexit -o pipefail -o nounset
main() {
declare tmp
tmp=$(mktemp)
cat > "$tmp"
sed -rn 's/^ ([-a-z]+).*/\1/gp' "$tmp"
# Do not output single letter commands, it's not useful.
sed -rn 's/^ .*\(([a-z]+)\).*/\1/gp' "$tmp" \
| grep -v ^.$
# TODO missing: (reg, r) (multiple aliases)
}
main "$@"