;dev: shell-completion: fix/update commands list parsing

This commit is contained in:
Simon Michael 2024-09-14 17:27:41 -07:00
parent e330ec9424
commit 2b80910a59

View File

@ -1,16 +1,17 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Parse hledger's help and output all commands and command aliases in # Parse hledger's commands list and print all builtin command names and aliases.
# parenthesis. Do not output single letter command aliases, it's not useful. # Currently add-on commands are excluded, except for ui and web.
set -euo pipefail
set -euo pipefail
declare commands_help declare commands_help
commands_help=$(hledger) commands_help=$(hledger)
# Keep synced with `hledger` output and known add-ons (+-prefixed commands in Hledger.Cli.Commands.commandsList):
{ {
sed -rn 's/^[[:space:]]+([a-z][-a-z]+)[[:space:]]+.*/\1/p' <<< "$commands_help" sed -rn 's/^[[:space:]]([a-z][-a-z]+)[[:space:]]+.*/\1/p; /OTHER ADDONS/q' <<< "$commands_help"
sed -rn 's/^[[:space:]]+[a-z][-a-z]+[[:space:]]+\(([a-z][ ,a-z]+)\).*/\1/p' <<< "$commands_help" | sed -rn 's/^[[:space:]][a-z][-a-z]+[[:space:]]+\(([a-z][ ,a-z]+)\).*/\1/p' <<< "$commands_help"
sed 's/[[:space:]]*,[[:space:]]*/\n/g' | } \
sed '/^.$/d' | sed -r '/(iadd|edit|lots|bar|plot|autosync|interest|pricehist|check-fancyassertions|check-tagfiles|git|pijul)/d;' \
} | sed '/^hledger/d' | sort -u | sort -u
# Local Variables: # Local Variables:
# mode: sh # mode: sh