Skip to content

Add shell completion for valid --json flag values#3628

Merged
mislav merged 2 commits intotrunkfrom
json-flag-completion
May 17, 2021
Merged

Add shell completion for valid --json flag values#3628
mislav merged 2 commits intotrunkfrom
json-flag-completion

Conversation

@mislav
Copy link
Contributor

@mislav mislav commented May 12, 2021

$ gh pr view --json is<Tab>
isCrossRepository  isDraft

Notes:

Copy link
Contributor

@samcoe samcoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good to me. We have not added flag shell completion in the past, what is the reason for adding it for json? Are we worried about it not working across all shells? I know we have had issues opened up in the past about how poor the completions work in some shells.

@mislav
Copy link
Contributor Author

mislav commented May 17, 2021

We have not added flag shell completion in the past, what is the reason for adding it for json?

We haven't, but --json has a static set of supported fields that users might need help spelling correctly, so shell completion is a great tool to help them out there. We can start adding completions for other flags as well— it's just that we'd have to hit the API to determine allowed values for most other flags, so that project will be slightly more complex.

Are we worried about it not working across all shells?

It will work across bash, zsh, fish, and PowerShell due to Cobra's recently improved completion support. When it doesn't, it's an issue that we should raise in Cobra's issue tracker.

@mislav mislav merged commit f2456f4 into trunk May 17, 2021
@mislav mislav deleted the json-flag-completion branch May 17, 2021 10:47
@mislav mislav mentioned this pull request May 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants