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

Add shell completion support #1076

Merged
merged 1 commit into from
Sep 26, 2024
Merged

Conversation

evelikov
Copy link
Contributor

@evelikov evelikov commented Sep 22, 2024

Add shell completion support via python-shtab. The reuse project/maitnainer/end-user can generate the static shell completion (currently bash, tcsh and zsh, with fish in progress) file via the reuse --print-completion SHELL command.

  • Added a change log entry in changelog.d/<directory>/.
  • Added self to copyright blurb of touched files.
  • Added self to AUTHORS.rst.
  • Wrote tests.
  • Documented my changes in docs/man/ or elsewhere.
  • My changes do not contradict
    the current specification.
  • I agree to license my contribution under the licenses indicated in the
    changed files.

This was referenced Sep 22, 2024
@evelikov evelikov force-pushed the shell-completion branch 4 times, most recently from 7103b2f to c2f11e8 Compare September 22, 2024 11:35
@evelikov
Copy link
Contributor Author

Note: my poetry knowledge is about zero, so I'm not sure what's the better way to handle the extra optional dependency.

The mypy workflow seems to be failing because of it. Any suggestions are deeply appreciated.

@evelikov evelikov mentioned this pull request Sep 22, 2024
6 tasks
@carmenbianca
Copy link
Member

Hi @evelikov and thanks for your contribution! This looks like an awesome little Python package. I have patched up the PR. I would love a review from you before merging.

@evelikov
Copy link
Contributor Author

Disclaimer: I'm not a python expert :-)

That said, the commits look good IMHO. Feel free to squash them if you prefer.

For commits:
df31c88 ("Add shell completion via python-shtab")
acfb363 ("Finish shell completion implementation")

Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>

Having a shell completion improves developers' workflow and makes it
easier for everyone to notice as the program gains new options.

This commit adds support for generatic static completion files via
shtab. Unlike other solutions which repeatedly invoke the underlying
program, to retrieve the next suggestion, shtab parses argparse options
and produces a complete static file.

It currently supports bash, tcsh and bash with PR opened for fish
support. For example, to generate zsh completion use:
 - reuse --print-completion zsh > /usr/share/zsh/site-functions/_reuse

This can be done by the reuse project itself, the package maintainer or
end-user.

For more details, see https://github.com/iterative/shtab

Closes: fsfe#629
Co-authored-by: Carmen Bianca BAKKER <carmenbianca@fsfe.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Carmen Bianca BAKKER <carmenbianca@fsfe.org>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com
@carmenbianca
Copy link
Member

Squashed, rebased, added a whole heap of tags to the commit, and ready to merge :) Thanks @evelikov !

@carmenbianca carmenbianca merged commit 29c3699 into fsfe:main Sep 26, 2024
15 checks passed
@evelikov evelikov deleted the shell-completion branch September 27, 2024 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants