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
completions: add ibmcloud #10004
completions: add ibmcloud #10004
Conversation
share/completions/ibmcloud.fish
Outdated
@@ -0,0 +1,11 @@ | |||
set -l commands (ibmcloud --generate-bash-completion) |
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.
What does this output look like? Could you give us a sample?
The "bash" part here is a bit suspect.
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 a newline separated list:
>ibmcloud --generate-bash-completion
resource
iam
dev
billing
plugin
network
gt
catalog
account
security
enterprise
sl
sat
ks
cs
oc
api
login
target
config
resources
update
logout
regions
version
>ibmcloud iam --generate-bash-completion
access-group
access-group-create
access-group-delete
access-group-policies
access-group-policy
access-group-policy-create
access-group-policy-delete
access-group-policy-update
access-group-service-id-add
access-group-service-id-purge
access-group-service-id-remove
access-group-service-ids
access-group-trusted-profile-add
ag-tp-add
...*truncated*
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.
Ah, that's what I thought.
It expects to be run like bash would run its completions. Importantly, that exports the commandline and where the cursor is.
If you don't do that, you only ever get the first argument, which isn't very helpful.
What you want is to run it with the same variables that bash would - like __fish_argcomplete_complete does.
(technically the additional file descriptors there aren't necessary, but they're unlikely to hurt)
Try something like
complete -c ibmcloud -f -a '(__fish_argcomplete_complete ibmcloud --generate-bash-completion)'
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.
Hmm, that works for the first command, but not for the secondary command(s):
>complete -c ibmcloud -f -a '(__fish_argcomplete_complete ibmcloud --generate-bash-completion)'
>complete -C 'ibmcloud '
account
api
billing
catalog
config
cs
dev
enterprise
gt
iam
ks
login
logout
network
oc
plugin
regions
resource
resources
sat
security
sl
target
update
version
>complete -C 'ibmcloud iam '
account
api
billing
catalog
config
cs
dev
enterprise
gt
iam
ks
login
logout
network
oc
plugin
regions
resource
resources
sat
security
sl
target
update
version
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.
Oh god, it's using half the bash completion system.
Okay, you need to arrange for the second to run ibmcloud iam --generate-bash-completion
.
You might want to try to run __fish_argcomplete_complete (commandline -opc) --generate-bash-completion
, or it needs to be more complicated.
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.
OK with complete -c ibmcloud -f -a '(__fish_argcomplete_complete (commandline -opc) --generate-bash-completion)'
oneliner I get the same result as my original commit.
Thanks, merged! |
* completions: add ibmcloud * Update ibmcloud.fish (cherry picked from commit d6e234c)
Adds completions for ibmcloud cli tool