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

Vagrant completion updates #1748

Closed
wants to merge 5 commits into
base: master
from

Conversation

Projects
None yet
2 participants
@zzamboni
Contributor

zzamboni commented Oct 10, 2014

Improved vagrant completions for some commands to avoid spurious completions, and added completions for some missing Vagrant commands.

zzamboni added some commits Oct 10, 2014

Avoid double command/subcommand completions
Fix the comparisons in argument numbers to avoid fish providing commands
or subcommands as completions after they have been provided already.
Fix box listing for Vagrant 1.1+
Recent versions of vagrant produce additional output in `vagrant box
list`, which was introducing spurious text in the completions.
Add completions for more vagrant commands
Add completions for recently-added commands connect, share,
global-status, login, rdp. Also improved the command comparisons to
improve completion of subcommands and their options.
@@ -32,7 +42,7 @@ function __fish_vagrant_using_subcommand
end

This comment has been minimized.

@kballard

kballard Oct 10, 2014

Contributor

Actually the whole function can be simplified again:

function __fish_vagrant_using_subcommand --arguments cmd_main cmd_sub
    set -l cmd (commandline -opc)
    set -q cmd[3]; and test "$cmd_main" = $cmd[2] -a "$cmd_sub" = $cmd[3]
end

Looks like the if [ $cmd_main ... command was actually wrong to begin with, since it was using an ; and in the condition without a begin/end block. Which is to say, it was never actually testing that the subcommand was correct.

@kballard

kballard Oct 10, 2014

Contributor

Actually the whole function can be simplified again:

function __fish_vagrant_using_subcommand --arguments cmd_main cmd_sub
    set -l cmd (commandline -opc)
    set -q cmd[3]; and test "$cmd_main" = $cmd[2] -a "$cmd_sub" = $cmd[3]
end

Looks like the if [ $cmd_main ... command was actually wrong to begin with, since it was using an ; and in the condition without a begin/end block. Which is to say, it was never actually testing that the subcommand was correct.

This comment has been minimized.

@zzamboni

zzamboni Oct 10, 2014

Contributor

Ooooh, this is the reason why the --provider flag was being offered as a completion to all the box subcommands! I wondered about that but never caught the mistake. Thanks!

@zzamboni

zzamboni Oct 10, 2014

Contributor

Ooooh, this is the reason why the --provider flag was being offered as a completion to all the box subcommands! I wondered about that but never caught the mistake. Thanks!

This comment has been minimized.

@zzamboni

zzamboni Oct 10, 2014

Contributor

And I just noticed the --arguments - very nice! Much cleaner than the usual shell way of fetching arguments.

@zzamboni

zzamboni Oct 10, 2014

Contributor

And I just noticed the --arguments - very nice! Much cleaner than the usual shell way of fetching arguments.

This comment has been minimized.

@kballard

kballard Oct 10, 2014

Contributor

Eh, when it works. It's basically equivalent to just

set -l cmd_main $argv[1]
set -l cmd_sub $argv[2]

except without array out of bound index errors.

But if you need to conditionally parse out flags or suchlike, it can end up being more annoying to work with than just $argv.

@kballard

kballard Oct 10, 2014

Contributor

Eh, when it works. It's basically equivalent to just

set -l cmd_main $argv[1]
set -l cmd_sub $argv[2]

except without array out of bound index errors.

But if you need to conditionally parse out flags or suchlike, it can end up being more annoying to work with than just $argv.

zzamboni added some commits Oct 10, 2014

Function simplifications
Simplifications and fixes as suggested by @kballard
Remove use of awk
Use `read` instead of `awk` to parse the box list.

@kballard kballard closed this in d982f2a Oct 10, 2014

@kballard

This comment has been minimized.

Show comment
Hide comment
@kballard

kballard Oct 10, 2014

Contributor

Squashed and pushed as d982f2a. Thanks!

Contributor

kballard commented Oct 10, 2014

Squashed and pushed as d982f2a. Thanks!

@kballard kballard added this to the next-minor milestone Oct 10, 2014

@zzamboni

This comment has been minimized.

Show comment
Hide comment
@zzamboni

zzamboni Oct 10, 2014

Contributor

Thanks!

Contributor

zzamboni commented Oct 10, 2014

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment