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

Support shell auto-completion #2376

Open
t1m0thyj opened this issue Nov 22, 2024 · 1 comment
Open

Support shell auto-completion #2376

t1m0thyj opened this issue Nov 22, 2024 · 1 comment
Labels
enhancement New feature or request new The issue wasn't triaged yet

Comments

@t1m0thyj
Copy link
Member

Is your feature or enhancement request related to a problem or limitation? Please describe

I wish that Tab auto-completion would be supported by Zowe CLI in popular shells like Bash and Zsh.

Describe your enhancement idea

Enable autocompletion in Zowe CLI with the yargs.completion API, which enables a zowe completion command to generate a shell script that can be added to ~/.bashrc or ~/.zshrc: https://yargs.js.org/docs/#api-reference-completioncmd-description-fn

Describe alternatives you've considered

I can launch web help to see command syntax, but this requires switching to a browser and is less context sensitive.

Provide any additional context

The configuration of Yargs for Zowe CLI happens in the YargsConfigurer class.

On MacOS the script generated by Yargs looks like this:

#compdef zowe
###-begin-zowe-completions-###
#
# yargs command completion script
#
# Installation: zowe completion >> ~/.zshrc
#    or zowe completion >> ~/.zprofile on OSX.
#
_zowe_yargs_completions()
{
  local reply
  local si=$IFS
  IFS=$'
' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" zowe --get-yargs-completions "${words[@]}"))
  IFS=$si
  _describe 'values' reply
}
compdef _zowe_yargs_completions zowe
###-end-zowe-completions-###

Note: The built-in autocompletion provided by Yargs works pretty well, but we may need to customize the yargs.completion handler to extract only the first line out of command descriptions, because multiple lines seem to mess it up.

@t1m0thyj t1m0thyj added enhancement New feature or request new The issue wasn't triaged yet labels Nov 22, 2024
@github-project-automation github-project-automation bot moved this to New Issues in Zowe CLI Squad Nov 22, 2024
Copy link

Thank you for raising this enhancement request.
The community has 90 days to vote on it.
If the enhancement receives at least 5 upvotes, it is added to our development backlog.
If it receives fewer votes, the issue is closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request new The issue wasn't triaged yet
Projects
Status: New Issues
Development

No branches or pull requests

1 participant