-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
feat(completions): add sops completions #8821
Conversation
share/completions/sops.fish
Outdated
end | ||
set -l cmd (commandline -cp) | ||
if set -q argv[2] | ||
if string match -qr -- "sops\s+$argv[1]\s+$argv[2]\s+\S*" $cmd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you try to replace uses of this function with __fish_seen_subcommand_from
?
I believe if there are multiple levels of subcommands, it's okay to use __fish_seen_subcommand_from subcmd && __fish_seen_subcommand_from subsubcmd
(not always fully correct but good enough)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean deleting this whole __fish_sops_commands
function and use __fish_seen_subcommand_from
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean deleting this whole
__fish_sops_commands
function and use__fish_seen_subcommand_from
instead?
yep
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
even better, replace it with a function that uses argparse to decide which subcommand is active (similar to __fish_sudo_print_remaining_args
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason why I didn't use __fish_seen_subcommand_from subcmd1 && __fish_seen_subcommand_from subcmd2
for multiple levels subcommands is because it accepts anything as long as there are the word subcmd1
and subcmd2
ignoring the placement. For example, if I want group
as subcmd1
and add
as subcmd2
then even if I write it as sops blablabla add groups
it will still return true. While the function that I'm using it right now (I took the code from __btrfs_commands
and __btrfs_command_groups
) will return false unless the command is sops groups add
and nothing else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might go with the even better "similar to __fish_sudo_print_remaining_args
" approach, but it might need some time because I'm still figuring out how does argparse
work. T.T
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok makes sense. I think copying __fish_sudo_print_remaining_args
is the way to go. We should probably add more examples to the argparse docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have modified the way it works, please have another look @krobelus. I don't know if the code is good as I'm not experienced enough for this (not even sure what I did lol), please correct my code if needed. :)
@krobelus Thanks for the reviews! I have commited some of your suggestions, and commented on those I don't quite understand. Please have another look :) |
yeah, no need to worry. We have some flaky tests. |
Thanks! |
Description
Add SoPS shell completion.
Issue I can't solve
sops --add-age "value" --decrypt
If I type insops --add-age
and put in the value that it needs, then I type in--
, it should give me list of flags that I can put in after that, but it shows me nothing but global flag. The workaround for user is to type it in like thissops --add-age="value" --decrypt
TODOs: