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

Generate shell completion scripts #256

Closed

Conversation

SimplyDanny
Copy link
Contributor

@SimplyDanny SimplyDanny commented Jan 15, 2022

Shell completion scripts are generated in every release build.

The build script requires access to the definition of the command line arguments and options Args. This struct is moved into its own file to be able to import it separately together with its types dependency.

clap_complete names the completion scripts tldr.bash, tldr.fish and _tldr, respectively. As it seems, these defaults cannot be changed. If the previous names are preferred, the files must be renamed in the build script after their generation.

The scripts are put into the completion directory where they are ignored from Git.

This PR closes #220.

@SimplyDanny
Copy link
Contributor Author

Hm ... I just noticed that the important dynamic completion of page names is unfortunately not yet supported by clap according to clap-rs/clap#1232.

@niklasmohrin
Copy link
Collaborator

That is quite unfortunate and, for me personally, a deal breaker. I still like the move of Args and of the completion files into their own directory (even when it is included in the three :D) and would keep those changes.

@dbrgn How do you feel about the generated completions?

@dbrgn
Copy link
Collaborator

dbrgn commented Jan 16, 2022

Hmm, that's unfortunate indeed, I did't realize that this is not possible. I agree that this is a deal breaker. For now, I'd close this, and if someone has the motivation, that person could open a feature request in the clap repo.

I also agree that moving the completions to a subdirectory makes sense.

Regarding the moving of CLI definitions into a separate module: At first I didn't like it, but after some more thinking about it, I think it's a good change.

@SimplyDanny do you want to open a new PR with the first commit, plus a commit that moves the completion files into a completions/ directory?

@SimplyDanny
Copy link
Contributor Author

Sure. I will prepare separate PRs for the accepted changes.

Keep in mind, though, that changes to the location of the completion scripts require updates of the packages (e.g. the Homebrew formula). I only generated them into an own folder, because their names would have changed anyway.

@dbrgn
Copy link
Collaborator

dbrgn commented Jan 16, 2022

Keep in mind, though, that changes to the location of the completion scripts require updates of the packages (e.g. the Homebrew formula). I only generated them into an own folder, because their names would have changed anyway.

Yes, I'm aware, but I think the change is worth it, because in the long run there may be additional completions as well, and if we keep them all in the root directory then it may get a bit messy.

(The main reason why I didn't rename/move them before was that I wanted to investigate clap-generated completions first, in which case we could have removed the completions from the repository entirely and only generate them for the releases 🙂)

@dbrgn
Copy link
Collaborator

dbrgn commented Jan 20, 2022

Superseded by #258 and #259. Thanks @SimplyDanny!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Auto-generate completion files through clap
3 participants