hledger/shell-completion/parse-commands.sh
Vladimir Zhelezov 5c2dd6fa2f Move back commands/options parsing to separate shell scripts
It made the Makefile more difficult to read and this way we can
take advantage of `set -e`, `-o pipefail` and friends.

Clean up debugging targets
2021-02-28 08:33:18 +01:00

14 lines
462 B
Bash
Executable File

#!/usr/bin/env bash
# Parse hledger's help and output all commands and command aliases in
# parenthesis. Do not output single letter command aliases, it's not useful.
set -euo pipefail
declare commands_help
commands_help=$(hledger)
{
sed -rn 's/^\s+([a-z][-a-z]+)\s+.*/\1/p' <<< "$commands_help"
sed -rn 's/^\s+[a-z][-a-z]+\s+\(([a-z][ ,a-z]+)\).*/\1/p' <<< "$commands_help" |
sed 's/\s*,\s*/\n/g' |
sed '/^.$/d'
} | sed '/^hledger/d' | sort -u