;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
# 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
# Parse hledger's commands list and print all builtin command names and aliases.
# Currently add-on commands are excluded, except for ui and web.
set -euo pipefail
declare commands_help
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:]]+\(([a-z][ ,a-z]+)\).*/\1/p' <<< "$commands_help" |
sed 's/[[:space:]]*,[[:space:]]*/\n/g' |
sed '/^.$/d'
} | sed '/^hledger/d' | sort -u
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 -r '/(iadd|edit|lots|bar|plot|autosync|interest|pricehist|check-fancyassertions|check-tagfiles|git|pijul)/d;' \
| sort -u
# Local Variables:
# mode: sh