Skip to content

Commit

Permalink
feat(ssh-keygen): complete -r/-Y specific -O args
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed May 2, 2024
1 parent b49ab1d commit d6977fc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
19 changes: 19 additions & 0 deletions completions/ssh-keygen
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ _comp_cmd_ssh_keygen()
generator=
)
;;
*\ -*r\ *)
opts=(hashalg=)
;;
*\ -*s\ *)
opts=(
clear critical: extension: force-command=
Expand All @@ -84,6 +87,9 @@ _comp_cmd_ssh_keygen()
resident user= verify-required write-attestation=
)
;;
*\ -*Y\ *)
opts=(hashalg= print-pubkey verify-time)
;;
esac
((${#opts[@]})) &&
_comp_compgen -- -W '"${opts[@]}"'
Expand All @@ -106,6 +112,19 @@ _comp_cmd_ssh_keygen()
user=*)
_comp_compgen -c "${cur#*=}" -- -u
;;
hashalg=*)
local -a args=()
case ${words[*]} in
*\ -*Y\ *)
args=(sha256 sha512)
;;
*\ -*r\ *)
args=(sha1 sha256)
;;
esac
((${#args[@]})) &&
_comp_compgen -c "${cur#*=}" -- -W '"${args[@]}"'
;;
esac
fi
return
Expand Down
8 changes: 8 additions & 0 deletions test/t/test_ssh_keygen.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,11 @@ def test_O_application_ssh_colon(self, completion):
)
def test_O_application_nonexistent(self, completion):
assert not completion

@pytest.mark.complete("ssh-keygen -r -O ")
def test_r_O(self, completion):
assert completion

@pytest.mark.complete("ssh-keygen -Y -O ")
def test_Y_O(self, completion):
assert completion

0 comments on commit d6977fc

Please sign in to comment.