-
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
Add completions for openbsd's doas #5196
Conversation
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.
Use the argparse, Luke!
share/completions/doas.fish
Outdated
end | ||
|
||
function __fish_doas_no_subcommand | ||
not __fish_doas_print_remaining_args >/dev/null |
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.
Conditions are already silenced, so there's no real need for this redirection and therefore function in general - just -n "not __fish_doas_print_remaining_args"
works.
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.
this is from the sudo completions :P I'll remove the function then.
# we want. | ||
if test -n "$argv" | ||
and not string match -qr '^-' $argv[1] | ||
echo $argv |
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.
This output isn't currently used, though I'd imagine you'll want to do so - see the sudo completions.
The reason that does the echo
is because it then uses that for complete -C
(--do-complete=
), which is better than using the stock __fish_complete_subcommand
function because it used argparse
to remove the options.
As an illustration of this general problem, imagine you had
git -C log status
as your commandline. What is the command here? If you knew nothing about git
, you'd say log
, with status
being an argument to it and -C
being a boolean flag. But actually the command is status
, because log
is an argument to the -C
option.
That's why argparse is useful, because it can solve those cases. You're almost there, but you need to do the last step.
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'll have a closer look at this. This is my first time writing completions and I couldn't find much documentation about it, so this is based on other completions.
share/completions/doas.fish
Outdated
not __fish_doas_print_remaining_args >/dev/null | ||
end | ||
|
||
complete -c doas -n "__fish_doas_no_subcommand" -s a -d "Choose auth method on openbsd systems" |
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.
"on openbsd systems" meaning this isn't implemented elsewhere?
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.
it's used on other systems than openbsd. I didn't feel the need to give an exhaustive list and was doing this based on the openbsd manpage, so I went with that. I'll change it to be system agnostic.
(I'm using a linux port of doas currently, so this is a bit confusing.)
share/completions/doas.fish
Outdated
end | ||
|
||
complete -c doas -n "__fish_doas_no_subcommand" -s a -d "Choose auth method on openbsd systems" | ||
complete -c doas -n "__fish_doas_no_subcommand" -s C -r -d "Parse and check given config file, then search for applying rules" |
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.
"search for applying rules"?
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.
With the -C flag, doas will look through it's configuration and see if any rule matches the supplied command. it will then print out what kind of rule matched.
share/completions/doas.fish
Outdated
|
||
complete -c doas -n "__fish_doas_no_subcommand" -s a -d "Choose auth method on openbsd systems" | ||
complete -c doas -n "__fish_doas_no_subcommand" -s C -r -d "Parse and check given config file, then search for applying rules" | ||
complete -c doas -n "__fish_doas_no_subcommand" -s L -d "Clear persisted authorizations, then immeadiately exit. No command is exectued" |
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.
Does it execute anything? I'm not quite sure 😄.
Descriptions should be kept short, so I'd say something like:
Clear persisted authorizations and exit
Alternatively sudo calls this "removing cached credentials".
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.
doas does what sudo does, but it's configuration is waay simpler and understandable.
I just copied the doas man page here :)
Merged, thanks! |
yay, thanks ^-^ |
TODOs: