|
| 1 | +# bash completion for osslsigncode -*- shell-script -*- |
| 2 | +# Copyright (C) 2021-2022 Michał Trojnara <Michal.Trojnara@stunnel.org> |
| 3 | +# Author: Małgorzata Olszówka <Malgorzata.Olszowka@stunnel.org> |
| 4 | + |
| 5 | +bind 'set show-all-if-ambiguous on' |
| 6 | +bind 'set completion-ignore-case on' |
| 7 | +COMP_WORDBREAKS=${COMP_WORDBREAKS//:} |
| 8 | + |
| 9 | +_comp_cmd_osslsigncode() |
| 10 | +{ |
| 11 | + local cur prev words cword |
| 12 | + _init_completion || return |
| 13 | + |
| 14 | + local commands command options timestamps rfc3161 |
| 15 | + |
| 16 | + commands="--help --version -v |
| 17 | + sign add attach-signature extract-signature remove-signature verify" |
| 18 | + |
| 19 | + timestamps="http://timestamp.digicert.com |
| 20 | + http://time.certum.pl |
| 21 | + http://timestamp.sectigo.com |
| 22 | + http://timestamp.globalsign.com/?signature=sha2" |
| 23 | + |
| 24 | + rfc3161="http://timestamp.digicert.com |
| 25 | + http://time.certum.pl |
| 26 | + http://timestamp.entrust.net/TSS/RFC3161sha2TS |
| 27 | + http://tss.accv.es:8318/tsa |
| 28 | + http://kstamp.keynectis.com/KSign/ |
| 29 | + http://sha256timestamp.ws.symantec.com/sha256/timestamp" |
| 30 | + |
| 31 | + |
| 32 | + if ((cword == 1)); then |
| 33 | + COMPREPLY=($(compgen -W "${commands}" -- ${cur})) |
| 34 | + else |
| 35 | + command=${words[1]} |
| 36 | + case $prev in |
| 37 | + -ac | -c | -catalog | -certs | -spc | -key | -pkcs12 | -pass | \ |
| 38 | + -readpass | -pkcs11engine | -pkcs11module | -in | -out | -sigin | \ |
| 39 | + -n | -CAfile | -CRLfile | -TSA-CAfile | -TSA-CRLfile) |
| 40 | + _filedir |
| 41 | + return |
| 42 | + ;; |
| 43 | + -h | -require-leaf-hash) |
| 44 | + COMPREPLY=($(compgen -W 'md5 sha1 sha2 sha256 sha384 sha512' \ |
| 45 | + -- "$cur")) |
| 46 | + return |
| 47 | + ;; |
| 48 | + -jp) |
| 49 | + COMPREPLY=($(compgen -W 'low medium high' -- "$cur")) |
| 50 | + return |
| 51 | + ;; |
| 52 | + -t) |
| 53 | + COMPREPLY=($(compgen -W "${timestamps}" -- "$cur")) |
| 54 | + return |
| 55 | + ;; |
| 56 | + -ts) |
| 57 | + COMPREPLY=($(compgen -W "${rfc3161}" -- "$cur")) |
| 58 | + return |
| 59 | + ;; |
| 60 | + -i | -p) |
| 61 | + _known_hosts_real -- "$cur" |
| 62 | + return |
| 63 | + ;; |
| 64 | + esac |
| 65 | + |
| 66 | + if [[ $cur == -* ]]; then |
| 67 | + # possible options for the command |
| 68 | + options=$(_parse_help "$1" "$command --help" 2>/dev/null) |
| 69 | + COMPREPLY=($(compgen -W "${options}" -- ${cur})) |
| 70 | + fi |
| 71 | + fi |
| 72 | + |
| 73 | +} && |
| 74 | + complete -F _comp_cmd_osslsigncode osslsigncode |
| 75 | + |
| 76 | +# ex: filetype=sh |
0 commit comments