Skip to content

Commit

Permalink
feat(openssl): openssl list -commands, not help
Browse files Browse the repository at this point in the history
In scop#1256 we started parsing
the help output. Get the list instead from the `openssl list -commands`
command.

This also stops completing the encryption and digest algorithms, since
those are usually used with the `enc` and `dgst` subcommands.

Suggested-By: Michael Newton
Fixes: scop#1324
  • Loading branch information
yedayak committed Feb 5, 2025
1 parent 4ac918f commit 69b976d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 4 additions & 1 deletion completions/openssl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ _comp_cmd_openssl__compgen_sections()

_comp_cmd_openssl__compgen_digests()
{
#_comp_compgen -W "$($1 list )"
#set -x
[[ $cur == -* ]] || return
_comp_compgen_split -- "$(
"$1" dgst -h 2>&1 |
Expand All @@ -35,6 +37,7 @@ _comp_cmd_openssl__compgen_digests()
_comp_compgen -ac "${cur#-}" split -P "-" -- "$("$1" help 2>&1 |
command sed -ne '/^Message Digest commands/,/^[[:space:]]*$/p' |
command sed -e 1d)"
set +x
}

_comp_cmd_openssl()
Expand All @@ -46,7 +49,7 @@ _comp_cmd_openssl()

if ((cword == 1)); then
local commands
commands="$("$1" help 2>&1 | command sed -e '/commands\|help:/d')"
commands="$("$1" list -commands)"
_comp_compgen -- -W "$commands"
else
command=${words[1]}
Expand Down
4 changes: 1 addition & 3 deletions test/t/test_openssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ class TestOpenssl:
@pytest.mark.complete("openssl ", require_cmd=True)
def test_1(self, completion):
assert completion
assert all(
x in completion for x in "md5 x509 aes-128-cbc dgst pkey".split()
)
assert all(x in completion for x in "x509 dgst pkey enc".split())

@pytest.mark.complete("openssl pkey -cipher ", require_cmd=True)
def test_2(self, completion):
Expand Down

0 comments on commit 69b976d

Please sign in to comment.