#compdef fpaste # Zsh completion for fpaste # Install: copy to ~/.zfunc/_fpaste and add 'fpath=(~/.zfunc $fpath)' to ~/.zshrc _fpaste() { local curcontext="$curcontext" state line typeset -A opt_args _arguments -C \ '-s[Server URL]:url:' \ '--server[Server URL]:url:' \ '-h[Show help]' \ '--help[Show help]' \ '1: :->command' \ '*:: :->args' case $state in command) local commands=( 'create:Create a new paste' 'c:Create a new paste' 'new:Create a new paste' 'get:Retrieve a paste' 'g:Retrieve a paste' 'delete:Delete paste(s)' 'd:Delete paste(s)' 'rm:Delete paste(s)' 'info:Show server info' 'i:Show server info' 'list:List your pastes' 'ls:List your pastes' 'search:Search your pastes' 's:Search your pastes' 'find:Search your pastes' 'update:Update existing paste' 'u:Update existing paste' 'export:Export all pastes' 'register:Register and get certificate' 'cert:Generate client certificate' 'pki:PKI operations' 'completion:Generate shell completion' ) _describe -t commands 'fpaste commands' commands ;; args) case $line[1] in create|c|new) _arguments \ '-E[Disable encryption]' \ '--no-encrypt[Disable encryption]' \ '-b[Burn after read]' \ '--burn[Burn after read]' \ '-x[Expiry in seconds]:seconds:' \ '--expiry[Expiry in seconds]:seconds:' \ '-p[Password protect]:password:' \ '--password[Password protect]:password:' \ '-r[Output raw URL]' \ '--raw[Output raw URL]' \ '-q[Output ID only]' \ '--quiet[Output ID only]' \ '-C[Read from clipboard]' \ '--clipboard[Read from clipboard]' \ '--copy-url[Copy result URL to clipboard]' \ '*:file:_files' ;; get|g) _arguments \ '-o[Save to file]:file:_files' \ '--output[Save to file]:file:_files' \ '-c[Copy content to clipboard]' \ '--copy[Copy content to clipboard]' \ '-p[Password]:password:' \ '--password[Password]:password:' \ '-m[Show metadata only]' \ '--meta[Show metadata only]' \ '1:paste ID:' ;; delete|d|rm) _arguments \ '-a[Delete all pastes]' \ '--all[Delete all pastes]' \ '-c[Confirm count]:count:' \ '--confirm[Confirm count]:count:' \ '*:paste ID:' ;; info|i) ;; list|ls) _arguments \ '-a[List all pastes (admin)]' \ '--all[List all pastes (admin)]' \ '-l[Max pastes]:number:' \ '--limit[Max pastes]:number:' \ '-o[Skip first N pastes]:number:' \ '--offset[Skip first N pastes]:number:' \ '--json[Output as JSON]' ;; search|s|find) _arguments \ '-t[Filter by MIME type]:pattern:' \ '--type[Filter by MIME type]:pattern:' \ '--after[Created after]:date:' \ '--before[Created before]:date:' \ '-l[Max results]:number:' \ '--limit[Max results]:number:' \ '--json[Output as JSON]' ;; update|u) _arguments \ '-E[Disable encryption]' \ '--no-encrypt[Disable encryption]' \ '-p[Set/change password]:password:' \ '--password[Set/change password]:password:' \ '--remove-password[Remove password]' \ '-x[Extend expiry]:seconds:' \ '--expiry[Extend expiry]:seconds:' \ '-q[Minimal output]' \ '--quiet[Minimal output]' \ '1:paste ID:' \ '*:file:_files' ;; export) _arguments \ '-o[Output directory]:directory:_files -/' \ '--output[Output directory]:directory:_files -/' \ '-k[Key file]:file:_files' \ '--keyfile[Key file]:file:_files' \ '--manifest[Write manifest.json]' \ '-q[Minimal output]' \ '--quiet[Minimal output]' ;; register) _arguments \ '-n[Common name]:name:' \ '--name[Common name]:name:' \ '-o[Output directory]:directory:_files -/' \ '--output[Output directory]:directory:_files -/' \ '--configure[Update config file]' \ '--p12-only[Save only PKCS#12]' \ '-f[Overwrite existing files]' \ '--force[Overwrite existing files]' \ '-q[Minimal output]' \ '--quiet[Minimal output]' ;; cert) _arguments \ '-o[Output directory]:directory:_files -/' \ '--output[Output directory]:directory:_files -/' \ '-a[Key algorithm]:algorithm:(rsa ec)' \ '--algorithm[Key algorithm]:algorithm:(rsa ec)' \ '-b[RSA key size]:bits:' \ '--bits[RSA key size]:bits:' \ '-c[EC curve]:curve:(secp256r1 secp384r1 secp521r1)' \ '--curve[EC curve]:curve:(secp256r1 secp384r1 secp521r1)' \ '-d[Validity period]:days:' \ '--days[Validity period]:days:' \ '-n[Common name]:name:' \ '--name[Common name]:name:' \ '--password-key[Encrypt private key]:password:' \ '--configure[Update config file]' \ '-f[Overwrite existing files]' \ '--force[Overwrite existing files]' ;; pki) local pki_commands=( 'status:Show PKI status' 'issue:Request certificate from server' 'download:Download CA certificate' 'dl:Download CA certificate' ) if (( CURRENT == 2 )); then _describe -t commands 'pki commands' pki_commands else case $line[2] in issue) _arguments \ '-n[Common name]:name:' \ '--name[Common name]:name:' \ '-o[Output directory]:directory:_files -/' \ '--output[Output directory]:directory:_files -/' \ '--configure[Update config file]' \ '-f[Overwrite existing files]' \ '--force[Overwrite existing files]' ;; download|dl) _arguments \ '-o[Save to file]:file:_files' \ '--output[Save to file]:file:_files' \ '--configure[Update config file]' ;; esac fi ;; completion) _arguments \ '--shell[Shell type]:shell:(bash zsh fish)' ;; esac ;; esac } _fpaste "$@"