tldr-pages / tlrc

A tldr client written in Rust
http://tldr.sh/tlrc/
MIT License
309 stars 11 forks source link

Add support for shell autocompletion for pages #50

Closed kbdharun closed 9 months ago

kbdharun commented 9 months ago

Currently, in tlrc v1.8.0 installed via brew, the autocompletion doesn't seem to support displaying page possibilities. i.e. If I type tldr aws and press tab, the output should show all the possibilities for aws subcommands.

We support this feature in all our official clients. It would be great if tlrc supports it too.

Ways to implement it

acuteenvy commented 9 months ago

Use an external command

There's an option in the config to change the cache directory. We can't hard-code the path in the completion script.

Use a native Rust library

This is the current approach - generate completions automatically using clap_complete. The downside of this is that everything the completion suggests has to be known at compile-time, so we can't use it either.

Parse and use our existing JSON index

That is certainly possible, but would require caching the index somewhere and using some kind of JSON parser in the completion script, which adds an extra dependency.


I think the best solution is to use the output of tldr --list-all.

kbdharun commented 9 months ago

I think the best solution is to use the output of tldr --list-all.

Yeah, that would work too.