-
Notifications
You must be signed in to change notification settings - Fork 27
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 basic bash completion script and framework for others #44
Conversation
extras/completions/floaty.bash
Outdated
hostname_subcommands="delete modify query revert snapshot" | ||
|
||
if [[ $template_subcommands =~ (^| )$prev($| ) ]] ; then | ||
if [ -z "$_vmfloaty_avail_templates" ] ; then |
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.
Consider using the extended test ([[
) instead of classic test ([
); should be essentially a drop-in here.
extras/completions/floaty.bash
Outdated
|
||
if [[ $template_subcommands =~ (^| )$prev($| ) ]] ; then | ||
if [ -z "$_vmfloaty_avail_templates" ] ; then | ||
_vmfloaty_avail_templates=`floaty list` |
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.
Consider $()
instead of ``; you used it elsewhere already so it's consistent.
extras/completions/floaty.bash
Outdated
COMPREPLY=( $(compgen -W "${subcommands}" -- ${cur}) ) | ||
fi | ||
} | ||
complete -F _vmfloaty floaty |
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.
Run this through shellcheck
?
This is a good feature. I only have some goofball nitpicks and I don't think they're worth blocking on. |
I can fix those issues up real quick. Also realized I should reject completion if cur starts with a |
41e967e
to
f331d19
Compare
Fixed up noted issues and a couple other little things. |
f331d19
to
7f63e75
Compare
|
||
```bash | ||
ln -s $(floaty completion --shell bash) /usr/local/etc/bash_completion.d/floaty | ||
``` |
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.
Hrm. Shortcoming: if you've installed floaty
as a gem or via the Homebrew tap I smashed together last year, this won't work.
mckern@flexor vmfloaty (git:add_bash_completion) $ (set -x; floaty completion --shell bash)
+ floaty completion --shell bash
mckern@flexor vmfloaty (git:add_bash_completion) $
extras/completions/floaty.bash
isn't actually installed anywhere right now by the gem, so it can't be referenced. Thoughts?
Oh, I think I just need to add the extras folder to the list of files in the gemspec. |
7f63e75
to
b53ef2c
Compare
OK, |
Can confirm:
|
Ping @briancain; when this is in and a release is cut, I'll update my homebrew tap. |
❤️ Thanks for all the feedback @mckern ! |
@scotje woot thanks for the contribution! I'll check this out later this morning and try it :) |
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.
Overall 👍 on this, I'm happy to see this tool still live on 💃 Just got a simple change for the help strings and then a question about maybe printing an error to STDERR
if an autocomplete file is missing but otherwise looks awesome!
lib/vmfloaty.rb
Outdated
command :completion do |c| | ||
c.syntax = 'floaty completion [options]' | ||
c.summary = 'Outputs path to completion script' | ||
c.description = "Outputs path to a completion script for the specified shell, or bash if not specified.\nWill exit non-zero if no completion script is available for the requested shell." |
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 think we should include the help text from the readme here just so people understand how to use this command (i.e. sourcing the file this command outputs) just so when people do floaty completion --help
they have some idea what to do with the command.
lib/vmfloaty.rb
Outdated
puts completion_file | ||
exit 0 | ||
else | ||
exit 1 |
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 make sense here to print a warning to STDERR in the case where the file requested is missing?
b53ef2c
to
6d57a1b
Compare
Updated with better |
ping @briancain Thanks for taking a look and have a nice weekend! |
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.
👍
Thanks Brian! ❤️ |
No description provided.