From 2b80910a59fc13b4f44545fc74834a261da13df1 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sat, 14 Sep 2024 17:27:41 -0700 Subject: [PATCH] ;dev: shell-completion: fix/update commands list parsing --- hledger/shell-completion/parse-commands.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/hledger/shell-completion/parse-commands.sh b/hledger/shell-completion/parse-commands.sh index 644a9936f..417998073 100755 --- a/hledger/shell-completion/parse-commands.sh +++ b/hledger/shell-completion/parse-commands.sh @@ -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