feat(completions): add sops completions#8821
feat(completions): add sops completions#8821krobelus merged 9 commits intofish-shell:masterfish-shell/fish-shell:masterfrom budimanjojo:masterCopy head branch name to clipboard
Conversation
| 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.
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.
Do you mean deleting this whole __fish_sops_commands function and use __fish_seen_subcommand_from instead?
There was a problem hiding this comment.
Do you mean deleting this whole
__fish_sops_commandsfunction and use__fish_seen_subcommand_frominstead?
yep
There was a problem hiding this comment.
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.
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.
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.
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.
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" --decryptIf I type insops --add-ageand 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" --decryptTODOs: