From 78d08455c0d176966b23a619b6b0045aa0d28531 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakob=20Sch=C3=B6ttl?= Date: Thu, 10 Jan 2019 19:13:28 +0100 Subject: [PATCH] Refactor helper script --- shell-completion/Makefile | 2 +- shell-completion/output-commands.sh | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/shell-completion/Makefile b/shell-completion/Makefile index 322a57204..5ecb1a4a9 100644 --- a/shell-completion/Makefile +++ b/shell-completion/Makefile @@ -7,7 +7,7 @@ generic-options.txt: hledger -h | ./output-options.sh > $@ commands.txt: - hledger | ./output-commands.sh > $@ + hledger | ./output-commands.sh | grep -v ^hledger > $@ commands-list.txt: commands.txt paste -sd, $^ | tr -d '\n' > $@ diff --git a/shell-completion/output-commands.sh b/shell-completion/output-commands.sh index 2bbc37996..44135a380 100755 --- a/shell-completion/output-commands.sh +++ b/shell-completion/output-commands.sh @@ -3,19 +3,14 @@ set -o errexit -o pipefail -o nounset -printCommands() { - declare tmp=$1 - sed -rn 's/^ ([-a-z]+).*/\1/gp' "$tmp" - sed -rn 's/^ .*\(([a-z]+)\).*/\1/gp' "$tmp" - # TODO missing: (reg, r) (multiple aliases) -} - main() { declare tmp tmp=$(mktemp) cat > "$tmp" - printCommands "$tmp" | grep -v ^hledger + sed -rn 's/^ ([-a-z]+).*/\1/gp' "$tmp" + sed -rn 's/^ .*\(([a-z]+)\).*/\1/gp' "$tmp" + # TODO missing: (reg, r) (multiple aliases) } main "$@"