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

[some help required] Add bash completions #542

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Fat-Zer
Copy link
Contributor

@Fat-Zer Fat-Zer commented Nov 13, 2024

I've sketched some bash completions. Nothing extra fancy just command-line options and some a couple of options with predefined values.

To test you may export BASH_COMPLETION_USER_DIR=/path/to/po4a/share/bash-completion/ and then play with po4a -<TAB><TAB> etc.

Note that the completions are using <script> --help, and since po4a has to process PODs to print it, the completions are lagging a bit (~200ms, not absolutely infuriating, but still noticeable and slightly annoying).


But I need some help with installation scripting, I have very little idea how to do it with perl. The files in share/bash-completion/completions are supposed to be installed to directory pointed by pkg-config --variable=completionsdir bash-completion. Usually it's /usr/share/bash-completion/completions.

PS: Also the commit contains several symlinks. I'm not sure if it's ok to store those in the sources. If not, those should be also created during build.

Closes: #417

Closes: mquinson#417
Signed-off-by: Alexander Golubev <[email protected]>
@gemmaro
Copy link
Contributor

gemmaro commented Jan 1, 2025

Can Getopt::Long::Complete (or alternatives) be used to support shell completion? (I haven't tried yet though)

@Fat-Zer
Copy link
Contributor Author

Fat-Zer commented Jan 1, 2025

@gemmaro It would resolve the issue with speed, but I'm a bit hesitant of introducing the dependency. If we make it required, it would be somewhat annoying for people who don't need it, and if we make it optional, it'd be either impossible to keep trek of it from the bash's side or nontrivial for maintainers to install.

Maybe instead we can add a flag that will just list the flags without help?

@gemmaro
Copy link
Contributor

gemmaro commented Jan 2, 2025

@Fat-Zer

It would resolve the issue with speed, but I'm a bit hesitant of introducing the dependency. If we make it required, it would be somewhat annoying for people who don't need it, and if we make it optional, it'd be either impossible to keep trek of it from the bash's side or nontrivial for maintainers to install.

Adding an optional completion package sounds like a good idea.
I think the optional dependency (in the recommends field in Build.PL) is great for packaging, since it doesn't break packages that are just version bumped.

Maybe instead we can add a flag that will just list the flags without help?

I like the way the completion script has granular control (e.g. --format in the change.) I wonder if it is possible to do this with listing flags.

@Fat-Zer
Copy link
Contributor Author

Fat-Zer commented Jan 2, 2025

Adding an optional completion package sounds like a good idea.

To be fair, I don't know about perl infrastructure enough to make this call neither it's my call to make anyway.

I think the optional dependency (in the recommends field in Build.PL) is great for packaging, since it doesn't break packages that are just version bumped.

The problem with this is that you will have to have a bash_completion file around anyway. And how to communicate to the maintainer whether the file is needed? If we just won't install it, the opportunity for completion will be unnoticeable for end-users. If we install it, there will be a problem that if the Getopt::Long::Complete is absent and a user tries to complete something it will result in an incorrect call... I'm not sure how to resolve all this in a sane-ish manner...

I wonder if it is possible to do this with listing flags.

You mean po4a's modules' options? Unfortunately as for now it won't be trivial as there are no way to query a module which options it supports.

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.

Please provide a bash completion file for the po4a script
2 participants