Improve ssh-sign function
Add -h option, don't require argument
This commit is contained in:
parent
151f91fb24
commit
c2f45d5661
|
@ -1,9 +1,13 @@
|
||||||
#compdef ssh-sign
|
#compdef ssh-sign
|
||||||
|
|
||||||
_arguments '-f[keyfile]:filename:_files' '-n[namespace]:namespace:_ssh-sign_namespaces' '*:file:_files'
|
_arguments '-f[key file]:filename:_files' '-n[namespace]:namespace:_ssh-sign_namespaces' '*:file:_files' '-h[short help text]'
|
||||||
|
|
||||||
function _ssh-sign_namespaces()
|
function _ssh-sign_namespaces()
|
||||||
{
|
{
|
||||||
local -a namespaces=(file email git "@$(dnsdomainname)")
|
local -a namespaces=(file email git "@$(dnsdomainname)")
|
||||||
_values "namespace" ${namespaces}
|
_values "namespace" ${namespaces}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode: shell-script
|
||||||
|
# End:
|
||||||
|
|
|
@ -4,11 +4,15 @@
|
||||||
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
|
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
|
||||||
|
|
||||||
autoload -U die
|
autoload -U die
|
||||||
[[ ${ARGC} -eq 0 ]] && die 1 "Usage: ${0} [-f KEYFILE] [-n NAMESPACE] <file> …"
|
|
||||||
|
|
||||||
zmodload zsh/zutil
|
zmodload zsh/zutil
|
||||||
local -a keyfile=(-f ~/.ssh/id_ed25519)
|
local -a keyfile=(-f ~/.ssh/id_ed25519)
|
||||||
local -a namespace=(-n file)
|
local -a namespace=(-n file)
|
||||||
zparseopts -D -K -- f:=keyfile n:=namespace
|
local -a help=()
|
||||||
|
zparseopts -D -K -- f:=keyfile n:=namespace h=help
|
||||||
|
if [[ ${#help} -ne 0 ]]; then
|
||||||
|
print "Usage: ${0} [-h] [-f KEYFILE] [-n NAMESPACE] <file> …"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
ssh-keygen -Y sign -f ${keyfile[2]} -n ${namespace[2]} ${@}
|
ssh-keygen -Y sign -f ${keyfile[2]} -n ${namespace[2]} ${@}
|
||||||
|
|
Loading…
Reference in New Issue