From a34110ee852704f2e8745e404178b8a3331bd648 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hermann?= Date: Thu, 2 Apr 2026 23:34:13 +0200 Subject: [PATCH] Fix zsh store completion definition --- cmd/cloudstic/completion.go | 11 ++++++++--- cmd/cloudstic/completion_test.go | 5 +++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/cmd/cloudstic/completion.go b/cmd/cloudstic/completion.go index b61b9a7..752229a 100644 --- a/cmd/cloudstic/completion.go +++ b/cmd/cloudstic/completion.go @@ -265,6 +265,12 @@ func completionZsh(w io.Writer) { # zsh completion for cloudstic +_cloudstic_store_prefixes() { + local -a values + values=('local:' 's3:' 'b2:' 'sftp://') + compadd -Q -S '' -X 'store URI prefix' -- "${values[@]}" +} + _cloudstic() { local -a commands commands=( @@ -290,7 +296,7 @@ _cloudstic() { local -a global_flags global_flags=( - '-store[Storage backend URI (local:, s3:[/], b2:[/], sftp://[user@]host[:port]/)]:uri:' + '-store[Storage backend URI]:uri:_cloudstic_store_prefixes' '-profile[Profile name from profiles.yaml]:name:' '-profiles-file[Path to profiles YAML file]:path:_files' '-s3-endpoint[S3 compatible endpoint URL]:url:' @@ -320,7 +326,6 @@ _cloudstic() { '-json[Write command result as JSON to stdout]' '-debug[Log every store request]' ) - # Check if a subcommand has been given local cmd local -i i=2 @@ -692,7 +697,7 @@ _cloudstic() { esac } -_cloudstic "$@" +compdef _cloudstic cloudstic `) } diff --git a/cmd/cloudstic/completion_test.go b/cmd/cloudstic/completion_test.go index 8c7a240..852dd36 100644 --- a/cmd/cloudstic/completion_test.go +++ b/cmd/cloudstic/completion_test.go @@ -56,7 +56,8 @@ func TestCompletionZsh(t *testing.T) { for _, marker := range []string{ "#compdef cloudstic", "_cloudstic()", - `_cloudstic "$@"`, + "_cloudstic_store_prefixes()", + "compdef _cloudstic cloudstic", // Commands with descriptions "init:Initialize a new repository", "backup:Create a new backup snapshot", @@ -78,7 +79,7 @@ func TestCompletionZsh(t *testing.T) { "passwd:Change the repository password", "-new-password[New repository password]", // Global flags with descriptions - "-store[Storage backend URI", + "-store[Storage backend URI]:uri:_cloudstic_store_prefixes", "-verbose[Log detailed operations]", // Subcommand-specific flags "-add-recovery-key[Generate a 24-word recovery key]",