Skip to content

Conversation

mikkoi
Copy link

@mikkoi mikkoi commented Oct 4, 2025

Issue #317

@akinomyoga
Copy link

There doesn't seem to be an existing directory share in the repository. I'm not sure it's worth introducing new trees like share just to add a completion file.

The installation should be performed automatically within a process instructed in Install, such as make install, rather than telling users to copy the file manually.

@mikkoi
Copy link
Author

mikkoi commented Oct 5, 2025

CPAN distributions are operating system agnostic.
There is no defined way to install anything which does not install into a Perl installation tree.
The operating system packaging teams would deal with the issue, e.g. DebianPerlGroup.

@mikkoi
Copy link
Author

mikkoi commented Oct 5, 2025

Thank you for your help, @akinomyoga .
I have modified the script to follow more closely to the rules in scop/bash-completion. Not everything. For instance, I haven't used any of the convenient functions provided by [bash-completion}(https://github.com/scop/bash-completion/blob/main/bash_completion).

I also changed mech-dump so that the command line options will always match with the current options.
I did this by adding a new command line option: --completions. This will use the same options which are given to GetOptions() for parsing. This is better than reading the output from --help, I think.

Copy link

@akinomyoga akinomyoga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CPAN distributions are operating system agnostic. There is no defined way to install anything which does not install into a Perl installation tree. The operating system packaging teams would deal with the issue, e.g. DebianPerlGroup.

Thank you for explaining the special situation with the CPAN distributions. OK, I'm not familiar with Perl installations anyway.

For instance, I haven't used any of the convenient functions provided by [bash-completion}(https://github.com/scop/bash-completion/blob/main/bash_completion).

_init_completion is a utility function provided by scop/bash-completion, though it doesn't seem to be used in the current version. See also the following code-change suggestion.

I also changed mech-dump so that the command line options will always match with the current options.

Thank you for updating the completion. This is the ideal approach.

Copy link

@akinomyoga akinomyoga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it is better to use only letters, numbers, and underscores in function names.

@mikkoi
Copy link
Author

mikkoi commented Oct 5, 2025

I have opened discussion with Debian Perl Group. I have been in contact before.
https://lists.debian.org/debian-perl/2025/10/msg00006.html

We could ask other platform packagers but I do not know how to reach others.

mikkoi added 4 commits October 5, 2025 15:26
Suppress:
    * SC2207, Prefer mapfile or read -a to split command output (or quote to avoid splitting).
    * SC2016, Expressions don't expand in single quotes, use double quotes for that.
@mikkoi mikkoi force-pushed the add-bash-completion branch from 51d4ebc to 40d841c Compare October 5, 2025 13:40
@mikkoi
Copy link
Author

mikkoi commented Oct 5, 2025

s there any policy in this area?

I don't think so.

  • How to include shell completion scripts in a CPAN distribution?

That's more of a question for the CPAN folks 🙂

Examples I find locally are:

  • rex: puts them in share/
  • minilla: under contrib/
  • distzilla: under misc/
  • Module::Build: under contrib/
  • Does the group take any action if there is shell completion scripts included in a distro?

Yes, if we see a bash or zsh completion script in a CPAN distribution, we will typically install it. (And it doesn't matter in which subdirectory they are shipped and how the files are named.)

E.g. for rex the completions end up as

  • /usr/share/bash-completion/completions/rex
  • /usr/share/zsh/vendor-completions/_rex

https://lists.debian.org/debian-perl/2025/10/msg00007.html

@mikkoi
Copy link
Author

mikkoi commented Oct 5, 2025

The completion scripts are sometimes done by others, the users of the software, not the developers.

So contrib/ might really be the correct place.

@oalders
Copy link
Member

oalders commented Oct 6, 2025

We could ask other platform packagers but I do not know how to reach others

I wonder if @michal-josef-spacek has an opinion?

@oalders oalders requested a review from Copilot October 9, 2025 19:22
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds Bash completion support for the mech-dump command-line tool. The implementation generates completion options dynamically by parsing the command-line options defined in the script.

  • Added a Bash completion script that uses mech-dump --completions to generate completion options
  • Enhanced the mech-dump script to support a --completions flag that outputs available command-line options
  • Included documentation for installing the Bash completion script

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
share/bash-completion/completions/mech-dump New Bash completion script that integrates with the completion system
share/README.md Documentation for installing the completion script
script/mech-dump Added --completions option and refactored option parsing to enable dynamic completion generation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@michal-josef-spacek
Copy link

We could ask other platform packagers but I do not know how to reach others

I wonder if @michal-josef-spacek has an opinion?

There are 4 Perl packages in Fedora:

  • App::Cme - contrib/bash_completion.cme
  • App::PFT - bash_completion.d/pft
  • Config::Model::Itself - contrib/bash_completion.cme_meta
  • Dist::Zilla - misc/dzil-bash_completion

@mikkoi
Copy link
Author

mikkoi commented Oct 10, 2025

We could ask other platform packagers but I do not know how to reach others

I wonder if @michal-josef-spacek has an opinion?

There are 4 Perl packages in Fedora:

* App::Cme - contrib/bash_completion.cme

* App::PFT - bash_completion.d/pft

* Config::Model::Itself - contrib/bash_completion.cme_meta

* Dist::Zilla - misc/dzil-bash_completion

Thank you.
Seems like here contrib is again the most popular.

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.

4 participants