Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions cmd/cloudstic/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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=(
Expand All @@ -290,7 +296,7 @@ _cloudstic() {

local -a global_flags
global_flags=(
'-store[Storage backend URI (local:<path>, s3:<bucket>[/<prefix>], b2:<bucket>[/<prefix>], sftp://[user@]host[:port]/<path>)]: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:'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -692,7 +697,7 @@ _cloudstic() {
esac
}

_cloudstic "$@"
compdef _cloudstic cloudstic
`)
}

Expand Down
5 changes: 3 additions & 2 deletions cmd/cloudstic/completion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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]",
Expand Down
Loading