2021-05-05 21:42:36 +00:00
|
|
|
if string match -q "OpenSSL*" (command openssl version)
|
|
|
|
# This is real OpenSSL that has the list command.
|
|
|
|
function __fish_openssl_subcommand_options --description "Print options for openssl subcommand"
|
2024-01-22 06:42:45 +00:00
|
|
|
set -l cmd (commandline -pxc)
|
2021-05-05 21:42:36 +00:00
|
|
|
openssl list -options $cmd[2] | string replace -r -- '^(\S*)\s*.*' '-$1'
|
|
|
|
end
|
|
|
|
|
2020-10-10 16:53:57 +00:00
|
|
|
complete -c openssl -n __fish_use_subcommand -x -a "(openssl list -1 -commands -cipher-commands -digest-commands)"
|
2021-05-05 21:42:36 +00:00
|
|
|
complete -c openssl -n 'not __fish_use_subcommand && string match -qr -- "^-" (commandline -ct)' -a "(__fish_openssl_subcommand_options)"
|
2020-10-10 16:53:57 +00:00
|
|
|
else
|
2021-05-05 21:42:36 +00:00
|
|
|
# Perhaps LibreSSL - see #7966
|
|
|
|
# TODO: support subcommand options.
|
|
|
|
complete -c openssl -n __fish_use_subcommand -x -a "(openssl help 2>&1 | string match -rv '^[A-Z]|^\$|Error' | string split -n ' ')"
|
2020-10-10 16:53:57 +00:00
|
|
|
end
|