From 6c2eeb4c9b901836fa8392b657bc9acdd93d3403 Mon Sep 17 00:00:00 2001 From: Tobias Reisinger Date: Fri, 12 Jan 2024 02:28:44 +0100 Subject: [PATCH] Improve completions workflow --- Makefile | 6 +----- autoinstall/bashly.yml | 6 +++++- autoinstall/file_command.sh | 9 +++++++++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 371b4de..2def80f 100644 --- a/Makefile +++ b/Makefile @@ -14,13 +14,9 @@ generate: get-target output-dir generate-upgrade: get-target output-dir BASHLY_SOURCE_DIR=$(TARGET) bashly generate --upgrade -completions: generate-upgrade - BASHLY_SOURCE_DIR=$(TARGET) bashly add --force completions_script ./output/_$(TARGET) - docs: generate BASHLY_SOURCE_DIR=$(TARGET) bashly render :mandoc ./output/man1 -deploy: completions docs +deploy: generate docs cp -f ./output/$(TARGET) ~/.local/bin/ - cp -f ./output/_$(TARGET) ~/.config/completionsrc.d/ cp -f ./output/man1/$(TARGET)*.1 ~/.local/share/man/man1/ diff --git a/autoinstall/bashly.yml b/autoinstall/bashly.yml index fec3458..3a382ae 100644 --- a/autoinstall/bashly.yml +++ b/autoinstall/bashly.yml @@ -1,6 +1,6 @@ name: autoinstall help: Install files, repository and else -version: 0.1.0 +version: 0.1.1 flags: - long: --clean @@ -73,6 +73,10 @@ commands: help: Pipe file through command (e.g. "tar xzO") arg: pipe default: cat + - long: --completions + short: -c + help: Run a command on the new exe to install completions + arg: completions - name: archive help: Install an archive diff --git a/autoinstall/file_command.sh b/autoinstall/file_command.sh index 2faa2dd..3f4abf3 100644 --- a/autoinstall/file_command.sh +++ b/autoinstall/file_command.sh @@ -3,6 +3,7 @@ pipe=${args[--pipe]:?} target=${args[target]:?} url=${args[url]:?} +completions=${args[completions]:-} if [ "${action:-file}" = "exe" ] then @@ -10,6 +11,7 @@ then then return fi + exe=$target target="$HOME/.local/bin/$target" fi @@ -27,6 +29,13 @@ then if [ "${action:-file}" = "exe" ] then chmod +x "$target" + + if [ -z "$completions" ] + then + echo "Installing completions for $exe" + # shellcheck disable=SC2086 + "$target" $completions > "$XDG_CONFIG_HOME/completionsrc.d/_$(basename "$exe")" + fi fi _run_hook