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.
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.
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?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.
Most helpful comment
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.