hledger/shell-completion/output-commands.sh

24 lines
533 B
Bash
Raw Normal View History

2019-01-10 21:08:46 +03:00
#!/bin/bash
# Output subcommands from man/usage text
set -o errexit -o pipefail -o nounset
main() {
declare tmp
tmp=$(mktemp)
cat > "$tmp"
# Do not output mistaken commands that start with a dash (e.g. -h)
sed -rn 's/^ ([-a-z]+).*/\1/gp' "$tmp" \
| grep -v ^-
# Output single command aliases in parenthesis:
# Do not output single letter command aliases, it's not useful.
sed -rn 's/^ .*\(([a-z]+)\).*/\1/gp' "$tmp" \
| grep -v ^.$
2019-01-10 21:13:28 +03:00
# TODO missing: (reg, r) (multiple aliases)
2019-01-10 21:08:46 +03:00
}
main "$@"