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

Script to generate completion from --help #4621

Closed
luc-j-bourhis opened this issue Dec 25, 2017 · 3 comments
Closed

Script to generate completion from --help #4621

luc-j-bourhis opened this issue Dec 25, 2017 · 3 comments

Comments

@luc-j-bourhis
Copy link
Contributor

Many command-line tools have an option --help which could be parse to automatically generate completions. Even if the result was not 100% perfect, this would be invaluable to lower the bar to provide fish completion. This is certainly a significant undertaking but one that is a worthy investment I reckon.

@faho
Copy link
Member

faho commented Dec 25, 2017

This has already been asked in #4081, and I feel like the rationale for closing that still applies.

To reiterate:

  • Blindly calling somecommand --help is dangerous

  • Generated completions are much less useful than hand-written ones

  • This is a bunch of work

  • If you would instead write a man page, you'd also help the upstream project

So I don't feel like it's worth it.

@faho faho closed this as completed Dec 25, 2017
@faho faho added the duplicate label Dec 25, 2017
@luc-j-bourhis
Copy link
Contributor Author

luc-j-bourhis commented Dec 25, 2017

#4981 seems to suggest on-the-fly completion. I meant a script to “pre-compile” a completion script, I.e. a sequence of calls to complete. This is what I meant by not 100% perfect: some manual editing may be necessary. On the other hand, from what you wrote, it seems there is a way to generate completion from man pages?

@faho
Copy link
Member

faho commented Dec 25, 2017

it seems there is a way to generate completion from man pages?

Yes - https://github.com/fish-shell/fish-shell/blob/master/share/tools/create_manpage_completions.py. This is run the first time fish is started, and can be refreshed by running fish_update_completions.

Which is probably an important bit of context - when you can already parse man pages (which is safe), there's really no real need to parse "--help" output for the very few utilities that have "--help" (or is it "-h" or "-?") but no man page.

Also that script shows the limitations of generating completions - you can do options to a mostly acceptable level of quality (though the descriptions are often bad), but anything else just isn't standardized enough.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants