Skip to content
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

Merged

Conversation

6A61736F6E206E61646572
Copy link
Contributor

Adds completions for ibmcloud cli tool

@@ -0,0 +1,11 @@
set -l commands (ibmcloud --generate-bash-completion)
Copy link
Member

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.

Copy link
Contributor Author

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*

image

Copy link
Member

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)'

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Contributor Author

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.

@faho faho added this to the fish 3.7.0 milestone Sep 9, 2023
@faho faho merged commit d6e234c into fish-shell:master Sep 9, 2023
6 of 7 checks passed
@faho
Copy link
Member

faho commented Sep 9, 2023

Thanks, merged!

faho pushed a commit that referenced this pull request Oct 8, 2023
* completions: add ibmcloud

* Update ibmcloud.fish

(cherry picked from commit d6e234c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants