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 fabric(deploy-tool) #4153
Conversation
share/completions/fab.fish
Outdated
if test -n "$_matched" | ||
set -l _task_name $_matched[2] | ||
set -l _task_desc $_matched[3] | ||
test -n "$task_desc"; or set -l _task_desc "No description" |
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.
Please just leave the description empty if there is none.
share/completions/fab.fish
Outdated
set -l _matched (string match -r "^ +([^ ]*) *([^ ]?.*)" $task) | ||
|
||
if test -n "$_matched" | ||
set -l _task_name $_matched[2] |
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.
You know... 13 hours ago I would have told you that this could lead to an "Array index out of bounds" error. But then we merged #4151.
😺
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 remove if test -n $_matched
and I confirmed that it works without problems!!
share/completions/fab.fish
Outdated
@@ -0,0 +1,75 @@ | |||
# tasks | |||
for task in (fab -l) |
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 should be put into a function that is then called via complete -c fab -a '(thatfunction)'
.
Otherwise these won't change if anything changes about the output (e.g. because you've switched to using a different file).
share/completions/fab.fish
Outdated
set -l _task_name $_matched[2] | ||
set -l _task_desc $_matched[3] | ||
test -n "$task_desc"; or set -l _task_desc "No description" | ||
complete -f -c fab -a "$_task_name" -d "$_task_desc" |
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.
Once this is in a function, you can do `printf "%s\t%s\n" "$_task_name" "$_task_desc" - the part after the tab character (\t) will be used as the description.
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.
That's what I wanted to know!!!!
improved 😄
Move for ~ end
to function __fish_complete_fab_tasks
.
And
Change like following:
complete -x -c fab -a "(__fish_complete_fab_tasks)"
share/completions/fab.fish
Outdated
complete -x -c fab -s g -l gateway -a " | ||
(__fish_print_hostnames) | ||
( | ||
echo (commandline -ct)|sed -ne 's/\(.*@\).*/\1/p' |
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 should be rewritten to use string replace
.
Something like commandline -ct | string replace -r '(.*@).*' '$1'
(the echo
is superfluous).
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.
Also, you're using this three times here (and we also do it in a few completions, including ssh and mosh), so a helper function would be adequate. If you'd like, put it into "share/functions/__fish_complete_user_at_host.fish" or so.
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.
fixed
I added helper function __fish_complete_user_at_host.fish
.
Can you confirm that I am not confident 😓
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.
Yes, it appears to work.
share/completions/fab.fish
Outdated
complete -c fab -l colorize-errors -d "Color error output" | ||
complete -c fab -s D -l disable-known-host -d "do not load user known_hosts file" | ||
complete -c fab -s e -l eagerly-disconnect -d "disconnect from hosts as soon as possible" | ||
complete -x -c fab -s f -l fabfile -d "python module file to import, e.g. '../other.py'" |
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 should actually use file completions, so remove the "-x".
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.
Fixed.
This option required argument, so added "-r" option.
correct??
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.
Yes, that should be okay.
share/completions/fab.fish
Outdated
complete -x -c fab -l show -d "comma-separated list of output levels to show" | ||
complete -c fab -l skip-bad-hosts -d "skip over hosts that can't be reached" | ||
complete -c fab -l skip-unknown-tasks -d "skip over unknown tasks" | ||
complete -x -c fab -l ssh-config-path -d "Path to SSH config file" |
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.
Also remove "-x".
This function list hostnames; if commandline hoge@~ , it list hoge@(hostname)
Description
Add
fab
completionshttp://www.fabfile.org/
example
fab -l
is displayed as follows:so fab-command completions as follows: