Skip to content

feat(ssh-keyscan): new completion #532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions completions/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ bashcomp_DATA = 2to3 \
ssh-add \
ssh-copy-id \
ssh-keygen \
ssh-keyscan \
sshfs \
sshmitm \
sshow \
Expand Down
39 changes: 39 additions & 0 deletions completions/ssh-keyscan
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# ssh-keyscan(1) completion -*- shell-script -*-

_comp_cmd_ssh_keyscan()
{
local cur prev words cword
_init_completion || return

local ipvx

case $prev in
-*4*)
ipvx=-4
;;
-*6*)
ipvx=-6
;;
-*f)
_filedir
return
;;
-*p | -*T)
return
;;
-*t)
_comp_delimited , -W "dsa ecdsa ed25519 rsa"
return
;;
esac

if [[ $cur == -* ]]; then
COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
return
fi

_known_hosts_real ${ipvx-} -- "$cur"
} &&
complete -F _comp_cmd_ssh_keyscan ssh-keyscan

# ex: filetype=sh
1 change: 1 addition & 0 deletions test/t/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ EXTRA_DIST = \
test_ssh_add.py \
test_ssh_copy_id.py \
test_ssh_keygen.py \
test_ssh_keyscan.py \
test_sshfs.py \
test_sshmitm.py \
test_sshow.py \
Expand Down
19 changes: 19 additions & 0 deletions test/t/test_ssh_keyscan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import pytest


@pytest.mark.bashcomp(
cmd="ssh-keyscan",
)
class TestSshKeyscan:
@pytest.mark.complete("ssh-keyscan ")
def test_basic(self, completion):
assert completion

@pytest.mark.complete("ssh-keyscan -", require_cmd=True)
def test_options(self, completion):
assert completion

@pytest.mark.complete("ssh-keyscan -t rsa,", require_cmd=True)
def test_type_delimited(self, completion):
assert completion
assert "rsa" not in completion
1 change: 1 addition & 0 deletions test/test-cmd-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ ssh
ssh-add
ssh-copy-id
ssh-keygen
ssh-keyscan
sshmitm
sshow
strace
Expand Down