Skip to content

Conversation

@fredricocalamari
Copy link

@fredricocalamari fredricocalamari commented Nov 6, 2024

Added zsh completion files. This feature allows zsh users to easily reference all options for keepassxc by typing into the zsh console:
keepassxc-cli command --<tab key>
--option1 --Description of option1
--option2 --Description of option2
...

I have included install.txt which contains instructions for end users and Linux distribution package maintaners on where it should be installed to.

Screenshots

image
image
image
image
image

Testing strategy

Place all of the _keepassxc* files (exclude install.txt) in the following folder:
/usr/share/zsh/site-functions/

Set permissions:
chmod 644 /usr/share/zsh/site-functions/_keepassxc*

Add the following lines to the file "~/.zshrc":
autoload -Uz compinit
compinit

Restart the terminal
Type into console "keepassxc-cli<space key>" then hit <tab key> to see the commands for the program.
Type in "keepassxc-cli edit -" then hit <tab key> to see the option arguments for the command.
It is possible to string options together, for example you can continue completing after "keepassxc-cli edit --key-file <file> by typing "<space key>-" and hitting <tab key> again to see additional options. The first option (e.g. --key-file in this example) does not appear again in the new list that appears since it was already used.

Type of change

  • ✅ New feature (change that adds functionality)
  • ✅ Documentation (non-code change)

@droidmonkey
Copy link
Member

Why do we need completions for keepassxc? If anything you should make them for keepassxc-cli

@droidmonkey droidmonkey marked this pull request as draft November 6, 2024 11:25
@fredricocalamari
Copy link
Author

fredricocalamari commented Nov 6, 2024

Why do we need completions for keepassxc? If anything you should make them for keepassxc-cli

You're right. I'll make completions for keepassxc-cli and resubmit.
I finished the completions, however I need to fix a small bug that made zsh unexpectedly complete the commands for keepassxc-cli when not invoking keepassxc-cli. For example, typing in "ls <space><tab key>" in zsh was invoking the _keepassxc-cli_ls function with compinit. Obviously, that's not ideal. I'll fix it shortly and resubmit for review.

@fredricocalamari fredricocalamari marked this pull request as ready for review November 7, 2024 11:15
@fredricocalamari fredricocalamari marked this pull request as draft November 7, 2024 21:56
@hueychen27
Copy link
Contributor

hueychen27 commented Nov 27, 2025

Here's my version which is very robust and built to be the most semantically accurate to the manpage and --help listings:

With credits of course:

# Greatest reference ever: https://zsh.sourceforge.io/Doc/Release/Completion-System.html#Completion-System
# This is wizardry
# Credits to _aptitude for showing usage of _describe
# Credits to /usr/share/zsh/functions/Completions/Linux/_ss for showing _arguments -s proper usage

_keepassxc:

#compdef keepassxc

_arguments -C -S -s \
    '(- 1 *)'{-h,--help}'[Displays help on commandline options.]' \
    '(- 1 *)'--help-all'[Displays help including Qt specific options.]' \
    '(- 1 *)'{-v,--version}'[Displays version information.]' \
    --config='[path to a custom config file]':'<config>':_files \
    --localconfig='[path to a custom local config file]':'<localconfig>':_files \
    --lock'[lock all open databases]' \
    --keyfile='[key file of the database]':'<keyfile>':_files \
    --pw-stdin'[read password of the database from stdin]' \
    '(- 1 *)'--debug-info'[Displays debugging information.]' \
    --allow-screencapture'[allows screenshots and app recording (Windows/macOS)]' \
    --minimized'[start minimized to the system tray]' \
    --qmljsdebugger='[Activates the QML/JS debugger with a specified port. The value must be of format port:1234[,block\]. "block" makes the application wait for a connection.]':'<value>' \
    --platform='[QPA plugin. See QGuiApplication documentation for available options for each plugin.]':'<platformName[\:options]>' \
    --platformpluginpath='[Path to the platform plugins.]':'<path>':'_files -/' \
    --platformtheme='[Platform theme.]':'<theme>' \
    --plugin='[Additional plugins to load, can be specified multiple times.]':'<plugin>' \
    --qwindowgeometry='[Window geometry for the main window, using the X11-syntax, like 100x100+50+50.]':'<geometry>' \
    --qwindowicon='[Default window icon.]':'<icon>' \
    --qwindowtitle='[Title of the first window.]':'<title>' \
    --reverse"[Sets the application's layout direction  to Qt::RightToLeft (debugging helper).]" \
    --session='[Restores the application from an earlier session.]':'<session>' \
    '*:filename(s):_files'

_keepassxc-cli:

#compdef keepassxc-cli

local curcontext="$curcontext" state lstate line
typeset -A opt_args

_show_cmd_message() {
    _message -r "$(keepassxc-cli $1 --help 2>&1 | grep -zoP 'Usage:.*\n.*(?=\n)')"
}

local -a subcmds

subcmds=(add':Add a new entry to a database.'
    analyze':Analyze passwords for weaknesses and problems.'
    'attachment-export:Export an attachment of an entry.'
    'attachment-import:Imports an attachment to an entry.'
    'attachment-rm:Remove an attachment of an entry.'
    "clip:Copy an entry's attribute to the clipboard."
    close':Close the currently opened database.'
    'db-create:Create a new database.'
    'db-edit:Edit a database.'
    "db-info:Show a database's information."
    diceware':Generate a new random diceware passphrase.'
    edit':Edit an entry.'
    estimate':Estimate the entropy of a password.'
    exit:'Exits interactive mode. Synonymous with quit. (Invalid subcommand)'
    export':Exports the content of a database to standard output in the specified format.'
    generate':Generate a new random password.'
    help':Display command help.'
    import':Import the contents of an XML database.'
    ls':List database entries.'
    merge':Merge two databases.'
    mkdir':Adds a new group to a database.'
    mv':Moves an entry to a new group.'
    open':Open a database.'
    quit':Exits interactive mode. Synonymous with exit. (Invalid subcommand)'
    rm':Remove an entry from the database.'
    rmdir':Removes a group from a database.'
    search':Find entries quickly.'
    show":Show an entry's information.")

_arguments -C -S -s \
    '(- 1 *)'--debug-info'[Displays debugging information.]' \
    '(- 1 *)'{-h,--help}'[Displays help on commandline options.]' \
    '(- 1 *)'--help-all'[Displays help including Qt specific options.]' \
    '(- 1 *)'{-v,--version}'[Displays version information.]' \
    ': :->cmds' \
    '*:: :->args'
case "$state" in
cmds)
    _describe -t commands 'keepassxc-cli [options] command' subcmds
    ;;
args)
    case $line[1] in
    add)
        _show_cmd_message $line[1]
        _arguments -C -S -s \
            '(-q --quiet)'{-q,--quiet}'[Silence password prompt and other secondary outputs.]' \
            '(-k --key-file)'{-k+,--key-file=}'[Key file of the database.]:<path>:_files' \
            --no-password'[Deactivate password key for the database.]' \
            '(-y --yubikey)'{-y+,--yubikey=}'[Yubikey slot and optional serial used to access the database (e.g., 1:7370001).]:<slot[\:serial]>' \
            '(-u --username)'{-u+,--username=}'[Username for the entry.]:<username>' \
            --url='[URL for the entry.]:<URL>:_urls' \
            --notes='[Notes for the entry.]:<Notes>' \
            '(-p --password-prompt)'{-p,--password-prompt}"[Prompt for the entry's password.]" \
            '(-g --generate)'{-g,--generate}"[Generate a password the entry.]" \
            '(-L --length)'{-L+,--length=}"[Length of the generated password]:<length>:_numbers" \
            '(-l --lower)'{-l,--lower}"[Use lowercase characters]" \
            '(-U --upper)'{-U,--upper}"[Use uppercase characters]" \
            '(-n --numeric)'{-n,--numeric}"[Use numbers]" \
            '(-s --special)'{-s,--special}"[Use special characters]" \
            '(-e --extended)'{-e,--extended}"[Use extended ASCII]" \
            '(-x --exclude)'{-x+,--exclude=}"[Exclude character set]:<chars>" \
            --exclude-similar"[Exclude similar looking characters]" \
            --every-group"[Include characters from every selected group]" \
            '(-c --custom)'{-c+,--custom=}"[Use custom character set]:<chars>" \
            '(-h --help)'{-h,--help}"[Display this help.]" \
            ':<database>:_files -g "*.kdbx"' \
            ':<entry>'
        ;;
    analyze)
        _show_cmd_message $line[1]
        _arguments -C -S -s \
            '(-q --quiet)'{-q,--quiet}'[Silence password prompt and other secondary outputs.]' \
            '(-k --key-file)'{-k+,--key-file=}'[Key file of the database.]:<path>:_files' \
            --no-password'[Deactivate password key for the database.]' \
            '(-y --yubikey)'{-y+,--yubikey=}'[Yubikey slot and optional serial used to access the database (e.g., 1:7370001).]:<slot[\:serial]>' \
            '(-H --hibp)'{-H+,--hibp=}'[Check if any passwords have been publicly leaked. FILENAME must be the path of a file listing SHA-1 hashes of leaked passwords in HIBP format, as available from https://haveibeenpwned.com/Passwords.]:<FILENAME>:_files' \
            --okon='[Path to okon-cli to search a formatted HIBP file.]:<okon-cli>' \
            '(-h --help)'{-h,--help}"[Display this help.]" \
            ':<database>:_files -g "*.kdbx"'
        ;;
    attachment-export)
        _show_cmd_message $line[1]
        _arguments -C -S -s \
            '(-q --quiet)'{-q,--quiet}'[Silence password prompt and other secondary outputs.]' \
            '(-k --key-file)'{-k+,--key-file=}'[Key file of the database.]:<path>:_files' \
            --no-password'[Deactivate password key for the database.]' \
            '(-y --yubikey)'{-y+,--yubikey=}'[Yubikey slot and optional serial used to access the database (e.g., 1:7370001).]:<slot[\:serial]>' \
            --stdout"[Output attachment's content to the standard output instead of <export_file>.]" \
            '(-h --help)'{-h,--help}"[Display this help.]" \
            ':<database>:_files -g "*.kdbx"' \
            ':<entry>' \
            ':<attachment_name>' \
            ':<export_file>:_files'
        ;;
    attachment-import)
        _show_cmd_message $line[1]
        _arguments -C -S -s \
            '(-q --quiet)'{-q,--quiet}'[Silence password prompt and other secondary outputs.]' \
            '(-k --key-file)'{-k+,--key-file=}'[Key file of the database.]:<path>:_files' \
            --no-password'[Deactivate password key for the database.]' \
            '(-y --yubikey)'{-y+,--yubikey=}'[Yubikey slot and optional serial used to access the database (e.g., 1:7370001).]:<slot[\:serial]>' \
            "(-f --force)"{-f,--force}"[Overwrite existing attachments.]" \
            '(-h --help)'{-h,--help}"[Display this help.]" \
            ':<database>:_files -g "*.kdbx"' \
            ':<entry>:_files' \
            ':<attachment_name>' \
            ':<import_file>:_files'
        ;;
    attachment-rm)
        _show_cmd_message $line[1]
        _arguments -C -S -s \
            '(-q --quiet)'{-q,--quiet}'[Silence password prompt and other secondary outputs.]' \
            '(-k --key-file)'{-k+,--key-file=}'[Key file of the database.]:<path>:_files' \
            --no-password'[Deactivate password key for the database.]' \
            '(-y --yubikey)'{-y+,--yubikey=}'[Yubikey slot and optional serial used to access the database (e.g., 1:7370001).]:<slot[\:serial]>' \
            "(-f --force)"{-f,--force}"[Overwrite existing attachments.]" \
            '(-h --help)'{-h,--help}"[Display this help.]" \
            ':<database>:_files -g "*.kdbx"' \
            ':<entry>' \
            ':<name>'
        ;;
    clip)
        _show_cmd_message $line[1]
        _arguments -C -S -s \
            '(-q --quiet)'{-q,--quiet}'[Silence password prompt and other secondary outputs.]' \
            '(-k --key-file)'{-k+,--key-file=}'[Key file of the database.]:<path>:_files' \
            --no-password'[Deactivate password key for the database.]' \
            '(-y --yubikey)'{-y+,--yubikey=}'[Yubikey slot and optional serial used to access the database (e.g., 1:7370001).]:<slot[\:serial]>' \
            '(-a --attribute)'{-a+,--attribute=}'[Copy the given attribute to the clipboard. Defaults to "password" if not specified.]:<attr>' \
            '(-t --totp)'{-t,--totp}'[Copy the current TOTP to the clipboard (equivalent to "-a totp").]' \
            '(-b --best-match)'{-b,--best-match}"[Must match only one entry, otherwise a list of possible matches is shown.]" \
            '(-h --help)'{-h,--help}"[Display this help.]" \
            ':<database>:_files -g "*.kdbx"' \
            ':<entry>:_files' \
            '::<timeout>:_numbers'
        ;;
    # close command in keepassxc-cli takes no arguments, not even --help
    close)
        _message -r "no arguments"
        ;;
    db-create)
        _show_cmd_message $line[1]
        _arguments -C -S -s \
            '(-q --quiet)'{-q,--quiet}'[Silence password prompt and other secondary outputs.]' \
            --set-key-file='[Set the key file for the database.]:<path>:_files' \
            -k+'[Set the key file for the database. This option is deprecated, use --set-key-file instead.]:<path>:_files' \
            '(-p --set-password)'{-p,--set-password}'[Copy the current TOTP to the clipboard (equivalent to "-a totp").]' \
            '(-t --decryption-time)'{-t+,--decryption-time=}"[Must match only one entry, otherwise a list of possible matches is shown.]:<time>:_numbers" \
            '(-h --help)'{-h,--help}"[Display this help.]" \
            ':<database>:_files -g "*.kdbx"'
        ;;
    db-edit)
        _show_cmd_message $line[1]
        _arguments -C -S -s \
            '(-q --quiet)'{-q,--quiet}'[Silence password prompt and other secondary outputs.]' \
            '(-k --key-file)'{-k+,--key-file=}'[Key file of the database.]:<path>:_files' \
            --no-password'[Deactivate password key for the database.]' \
            '(-y --yubikey)'{-y+,--yubikey=}'[Yubikey slot and optional serial used to access the database (e.g., 1:7370001).]:<slot[\:serial]>' \
            --set-key-file='[Set the key file for the database.]:<path>:_files' \
            '(-p --set-password)'{-p,--set-password}'[Set a password for the database.]' \
            --unset-key-file'[Unset the key file for the database.]' \
            --unset-password'[Unset the password for the database.]' \
            '(-h --help)'{-h,--help}"[Display this help.]" \
            ':<database>:_files -g "*.kdbx"'
        ;;
    db-info)
        _show_cmd_message $line[1]
        _arguments -C -S -s \
            '(-q --quiet)'{-q,--quiet}'[Silence password prompt and other secondary outputs.]' \
            '(-k --key-file)'{-k+,--key-file=}'[Key file of the database.]:<path>:_files' \
            --no-password'[Deactivate password key for the database.]' \
            '(-y --yubikey)'{-y,--yubikey}'[Yubikey slot and optional serial used to access the database (e.g., 1:7370001).]:<slot[\:serial]>' \
            '(-h --help)'{-h,--help}"[Display this help.]" \
            ':<database>:_files -g "*.kdbx"'
        ;;
    diceware)
        _show_cmd_message $line[1]
        _arguments -C -S -s \
            '(-q --quiet)'{-q,--quiet}'[Silence password prompt and other secondary outputs.]' \
            '(-W --words)'{-W+,--words=}'[Word count for the diceware passphrase.]:<count>:_numbers' \
            '(-w --word-list)'{-w+,--word-list=}'[Wordlist for the diceware generator. [Default: EFF English\]]:<path>:_files' \
            '(-h --help)'{-h,--help}"[Display this help.]"
        ;;
    edit)
        _show_cmd_message $line[1]
        _arguments -C -S -s \
            '(-q --quiet)'{-q,--quiet}'[Silence password prompt and other secondary outputs.]' \
            '(-k --key-file)'{-k+,--key-file=}'[Key file of the database.]:<path>:_files' \
            --no-password'[Deactivate password key for the database.]' \
            '(-y --yubikey)'{-y+,--yubikey=}'[Yubikey slot and optional serial used to access the database (e.g., 1:7370001).]:<slot[\:serial]>' \
            '(-u --username)'{-u+,--username=}'[Username for the entry.]:<username>' \
            --url='[URL for the entry.]:<URL>:_urls' \
            --notes='[Notes for the entry.]:<Notes>' \
            '(-p --password-prompt)'{-p,--password-prompt}"[Prompt for the entry's password.]" \
            '(-t --title)'{-t+,--title=}'[Title for the entry.]:<title>' \
            '(-g --generate)'{-g,--generate}"[Generate a password the entry.]" \
            '(-L --length)'{-L+,--length=}"[Length of the generated password]:<length>:_numbers" \
            '(-l --lower)'{-l,--lower}"[Use lowercase characters]" \
            '(-U --upper)'{-U,--upper}"[Use uppercase characters]" \
            '(-n --numeric)'{-n,--numeric}"[Use numbers]" \
            '(-s --special)'{-s,--special}"[Use special characters]" \
            '(-e --extended)'{-e,--extended}"[Use extended ASCII]" \
            '(-x --exclude)'{-x+,--exclude=}"[Exclude character set]:<chars>" \
            --exclude-similar"[Exclude similar looking characters]" \
            --every-group"[Include characters from every selected group]" \
            '(-c --custom)'{-c+,--custom=}"[Use custom character set]:<chars>" \
            '(-h --help)'{-h,--help}"[Display this help.]" \
            ':<database>:_files -g "*.kdbx"' \
            ':<entry>'
        ;;
    estimate)
        _show_cmd_message $line[1]
        _arguments -C -S -s \
            '(-q --quiet)'{-q,--quiet}'[Silence password prompt and other secondary outputs.]' \
            '(-a --advanced)'{-a,--advanced}'[Perform advanced analysis on the password.]' \
            '(-h --help)'{-h,--help}"[Display this help.]" \
            '::<password>'
        ;;
    exit)
        _message "invalid subcommand"
        ;;
    export)
        _show_cmd_message $line[1]
        _arguments -C -S -s \
            '(-q --quiet)'{-q,--quiet}'[Silence password prompt and other secondary outputs.]' \
            '(-k --key-file)'{-k+,--key-file=}'[Key file of the database.]:<path>:_files' \
            --no-password'[Deactivate password key for the database.]' \
            '(-y --yubikey)'{-y+,--yubikey=}'[Yubikey slot and optional serial used to access the database (e.g., 1:7370001).]:<slot[\:serial]>' \
            '(-f --format)'{-f+,--format=}"[Format to use when exporting. Available choices are 'xml', 'csv' or 'html'. Defaults to 'xml'.]:<xml|csv|html>:(xml csv html)" \
            '(-h --help)'{-h,--help}"[Display this help.]" \
            ':<database>:_files -g "*.kdbx"'
        ;;
    generate)
        _show_cmd_message $line[1]
        _arguments -C -S -s \
            '(-q --quiet)'{-q,--quiet}'[Silence password prompt and other secondary outputs.]' \
            '(-L --length)'{-L+,--length=}"[Length of the generated password]:<length>:_numbers" \
            '(-l --lower)'{-l,--lower}"[Use lowercase characters]" \
            '(-U --upper)'{-U,--upper}"[Use uppercase characters]" \
            '(-n --numeric)'{-n,--numeric}"[Use numbers]" \
            '(-s --special)'{-s,--special}"[Use special characters]" \
            '(-e --extended)'{-e,--extended}"[Use extended ASCII]" \
            '(-x --exclude)'{-x+,--exclude=}"[Exclude character set]:<chars>" \
            --exclude-similar"[Exclude similar looking characters]" \
            --every-group"[Include characters from every selected group]" \
            '(-c --custom)'{-c+,--custom=}"[Use custom character set]:<chars>" \
            '(-h --help)'{-h,--help}"[Display this help.]"
        ;;
    help)
        _arguments -C -S -s "1:: :->cmds"
        case $state in
        cmds)
            _describe -t commands 'keepassxc-cli help [command]' subcmds
            ;;
        esac
        ;;
    import)
        _show_cmd_message $line[1]
        _arguments -C -S -s \
            '(-q --quiet)'{-q,--quiet}'[Silence password prompt and other secondary outputs.]' \
            --set-key-file='[Set the key file for the database.]:<path>:_files' \
            -k+'[Set the key file for the database. This option is deprecated, use --set-key-file instead.]:<path>:_files' \
            '(-p --set-password)'{-p,--set-password}'[Copy the current TOTP to the clipboard (equivalent to "-a totp").]' \
            '(-t --decryption-time)'{-t+,--decryption-time=}"[Must match only one entry, otherwise a list of possible matches is shown.]:<time>:_numbers" \
            '(-h --help)'{-h,--help}"[Display this help.]" \
            ':<xml>:_files' \
            ':<database>:_files -g "*.kdbx"'
        ;;
    ls)
        _show_cmd_message $line[1]
        _arguments -C -S -s \
            '(-q --quiet)'{-q,--quiet}'[Silence password prompt and other secondary outputs.]' \
            '(-k --key-file)'{-k+,--key-file=}'[Key file of the database.]:<path>:_files' \
            --no-password'[Deactivate password key for the database.]' \
            '(-y --yubikey)'{-y+,--yubikey=}'[Yubikey slot and optional serial used to access the database (e.g., 1:7370001).]:<slot[\:serial]>' \
            '(-R --recursive)'{-R,--recursive}'[Recursively list the elements of the group.]' \
            '(-f --flatten)'{-f,--flatten}'[Flattens the output to single lines.]' \
            '(-h --help)'{-h,--help}"[Display this help.]" \
            ':<database>:_files -g "*.kdbx"' \
            '::<group>'
        ;;
    merge)
        _show_cmd_message $line[1]
        _arguments -C -S -s \
            '(-q --quiet)'{-q,--quiet}'[Silence password prompt and other secondary outputs.]' \
            '(-k --key-file)'{-k+,--key-file=}'[Key file of the database.]:<path>:_files' \
            --no-password'[Deactivate password key for the database.]' \
            '(-y --yubikey)'{-y+,--yubikey=}'[Yubikey slot and optional serial used to access the database (e.g., 1:7370001).]:<slot[\:serial]>' \
            '(-s --same-credentials)'{-s,--same-credentials}'[Use the same credentials for both database files.]' \
            --key-file-from='[Key file of the database to merge from.]:<path>:_files' \
            --no-password-from'[Deactivate password key for the database to merge from.]' \
            '(-d --dry-run)'{-d,--dry-run}'[Only print the changes detected by the merge operation.]' \
            --yubikey-from='[Yubikey slot for the second database.]:<slot>' \
            '(-h --help)'{-h,--help}"[Display this help.]" \
            ':<database>:_files -g "*.kdbx"' \
            ':<database2>:_files -g "*.kdbx"'
        ;;
    mkdir)
        _show_cmd_message $line[1]
        _arguments -C -S -s \
            '(-q --quiet)'{-q,--quiet}'[Silence password prompt and other secondary outputs.]' \
            '(-k --key-file)'{-k+,--key-file=}'[Key file of the database.]:<path>:_files' \
            --no-password'[Deactivate password key for the database.]' \
            '(-y --yubikey)'{-y+,--yubikey=}'[Yubikey slot and optional serial used to access the database (e.g., 1:7370001).]:<slot[\:serial]>' \
            '(-h --help)'{-h,--help}"[Display this help.]" \
            ':<database>:_files -g "*.kdbx"' \
            ':<group>'
        ;;
    mv)
        _show_cmd_message $line[1]
        _arguments -C -S -s \
            '(-q --quiet)'{-q,--quiet}'[Silence password prompt and other secondary outputs.]' \
            '(-k --key-file)'{-k+,--key-file=}'[Key file of the database.]:<path>:_files' \
            --no-password'[Deactivate password key for the database.]' \
            '(-y --yubikey)'{-y+,--yubikey=}'[Yubikey slot and optional serial used to access the database (e.g., 1:7370001).]:<slot[\:serial]>' \
            '(-h --help)'{-h,--help}"[Display this help.]" \
            ':<database>:_files -g "*.kdbx"' \
            ':<entry>' \
            ':<group>'
        ;;
    open)
        _show_cmd_message $line[1]
        _arguments -C -S -s \
            '(-q --quiet)'{-q,--quiet}'[Silence password prompt and other secondary outputs.]' \
            '(-k --key-file)'{-k+,--key-file=}'[Key file of the database.]:<path>:_files' \
            --no-password'[Deactivate password key for the database.]' \
            '(-y --yubikey)'{-y+,--yubikey=}'[Yubikey slot and optional serial used to access the database (e.g., 1:7370001).]:<slot[\:serial]>' \
            '(-h --help)'{-h,--help}"[Display this help.]" \
            ':<database>:_files -g "*.kdbx"'
        ;;
    quit)
        _message "invalid subcommand"
        ;;
    rmdir)
        _show_cmd_message $line[1]
        _arguments -C -S -s \
            '(-q --quiet)'{-q,--quiet}'[Silence password prompt and other secondary outputs.]' \
            '(-k --key-file)'{-k+,--key-file=}'[Key file of the database.]:<path>:_files' \
            --no-password'[Deactivate password key for the database.]' \
            '(-y --yubikey)'{-y+,--yubikey=}'[Yubikey slot and optional serial used to access the database (e.g., 1:7370001).]:<slot[\:serial]>' \
            '(-h --help)'{-h,--help}"[Display this help.]" \
            ':<database>:_files -g "*.kdbx"' \
            ':<group>'
        ;;
    rm)
        _show_cmd_message $line[1]
        _arguments -C -S -s \
            '(-q --quiet)'{-q,--quiet}'[Silence password prompt and other secondary outputs.]' \
            '(-k --key-file)'{-k+,--key-file=}'[Key file of the database.]:<path>:_files' \
            --no-password'[Deactivate password key for the database.]' \
            '(-y --yubikey)'{-y+,--yubikey=}'[Yubikey slot and optional serial used to access the database (e.g., 1:7370001).]:<slot[\:serial]>' \
            '(-h --help)'{-h,--help}"[Display this help.]" \
            ':<database>:_files -g "*.kdbx"' \
            ':<entry>'
        ;;
    search)
        _show_cmd_message $line[1]
        _arguments -C -S -s \
            '(-q --quiet)'{-q,--quiet}'[Silence password prompt and other secondary outputs.]' \
            '(-k --key-file)'{-k+,--key-file=}'[Key file of the database.]:<path>:_files' \
            --no-password'[Deactivate password key for the database.]' \
            '(-y --yubikey)'{-y+,--yubikey=}'[Yubikey slot and optional serial used to access the database (e.g., 1:7370001).]:<slot[\:serial]>' \
            '(-h --help)'{-h,--help}"[Display this help.]" \
            ':<database>:_files -g "*.kdbx"' \
            ':<term>'
        ;;
    show)
        _show_cmd_message $line[1]
        _arguments -C -S -s \
            '(-q --quiet)'{-q,--quiet}'[Silence password prompt and other secondary outputs.]' \
            '(-k --key-file)'{-k+,--key-file=}'[Key file of the database.]:<path>:_files' \
            --no-password'[Deactivate password key for the database.]' \
            '(-y --yubikey)'{-y+,--yubikey=}'[Yubikey slot and optional serial used to access the database (e.g., 1:7370001).]:<slot[\:serial]>' \
            '(-t --totp)'{-t,--totp}"[Show the entry's current TOTP.]" \
            '*'{-a+,--attributes=}'[Names of the attributes to show. This option can be specified more than once, with each attribute shown one-per-line in the given order. If no attributes are specified, a summary of the default attributes is given.]:<attribute>' \
            '(-s --show-protected)'{-s,--show-protected}'[Show the protected attributes in clear text.]' \
            --all'[Show all the attributes of the entry.]' \
            --show-attachments'[Show the attachments of the entry.]' \
            '(-h --help)'{-h,--help}"[Display this help.]" \
            ':<database>:_files -g "*.kdbx"' \
            ':<entry>'
        ;;
    *)
        _message "???"
        ;;
    esac
    ;;
esac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants