Compare commits
3 Commits
Author | SHA256 | Date | |
---|---|---|---|
44c55d6e14 | |||
0ea5fc802c | |||
a9cb130bb5 |
109
0001_fix_bashcompletion_with_subcommands.patch
Normal file
109
0001_fix_bashcompletion_with_subcommands.patch
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
diff --git a/lib/MooseX/App/Plugin/BashCompletion/Command.pm b/lib/MooseX/App/Plugin/BashCompletion/Command.pm
|
||||||
|
index afe5c66..cdc1bc2 100644
|
||||||
|
--- a/lib/MooseX/App/Plugin/BashCompletion/Command.pm
|
||||||
|
+++ b/lib/MooseX/App/Plugin/BashCompletion/Command.pm
|
||||||
|
@@ -17,8 +17,10 @@ sub bash_completion {
|
||||||
|
my %command_map;
|
||||||
|
my $app_meta = $app->meta;
|
||||||
|
my $commands = $app_meta->app_commands;
|
||||||
|
- my @commands_to_complete = grep { $_ ne 'bash_completion' } sort keys %{$commands};
|
||||||
|
- my $command_list = join (' ', @commands_to_complete);
|
||||||
|
+ my @filtered_cmds = grep { $_ ne 'bash_completion' } keys %{$commands};
|
||||||
|
+ my %unique_cmds = map { my @c = split ' ', $_; ($c[0], 1); } @filtered_cmds;
|
||||||
|
+ my @cmds2complete = sort(@filtered_cmds);
|
||||||
|
+ my $command_list = join (' ', sort(keys(%unique_cmds)));
|
||||||
|
my $package = __PACKAGE__;
|
||||||
|
my $prefix = $app_meta->app_base;
|
||||||
|
|
||||||
|
@@ -29,14 +31,17 @@ sub bash_completion {
|
||||||
|
|
||||||
|
$prefix =~ tr/./_/;
|
||||||
|
|
||||||
|
- foreach my $command (@commands_to_complete) {
|
||||||
|
+ foreach my $command (@cmds2complete) {
|
||||||
|
my $command_class = $commands->{$command};
|
||||||
|
Class::Load::load_class($command_class);
|
||||||
|
- #my @parameters = $app_meta->command_usage_attributes($command_class->meta,'parameter');
|
||||||
|
- my @options = $app_meta->command_usage_attributes($command_class->meta,[qw(option proto)]);
|
||||||
|
+ my @sub_map = map { $_ =~ /^${command} (\w+)/; $1; } sort(@filtered_cmds);
|
||||||
|
+ my @sub_cmds = grep { defined $_ } @sub_map;
|
||||||
|
+ my @options = $app_meta->command_usage_attributes(
|
||||||
|
+ $command_class->meta,
|
||||||
|
+ [qw(option proto)],
|
||||||
|
+ );
|
||||||
|
$command_map{$command} = {
|
||||||
|
- #parameters => [ map { $_->is_required } @parameters ],
|
||||||
|
- options => [ map { $_->cmd_usage_name } @options ],
|
||||||
|
+ options => [@sub_cmds, sort(map { $_->cmd_usage_name } @options)],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -60,9 +65,11 @@ _${prefix}_macc_help() {
|
||||||
|
EOT
|
||||||
|
|
||||||
|
foreach my $command (sort keys %command_map) {
|
||||||
|
- $syntax .= "_${prefix}_macc_${command}() {\n _${prefix}_compreply \"";
|
||||||
|
+ my $fn_suffix = $command;
|
||||||
|
+ $fn_suffix =~ s/ /_/g;
|
||||||
|
+ $syntax .= "_${prefix}_macc_${fn_suffix}() {\n _${prefix}_compreply \"";
|
||||||
|
#$syntax .= join(" ", @{$data->{parameters}});
|
||||||
|
- $syntax .= join(" ", sort @{$command_map{$command}->{options}});
|
||||||
|
+ $syntax .= join(" ", @{$command_map{$command}->{options}});
|
||||||
|
$syntax .= "\"\n}\n\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/t/08_plugin_various.t b/t/08_plugin_various.t
|
||||||
|
index d84ad23..179431e 100644
|
||||||
|
--- a/t/08_plugin_various.t
|
||||||
|
+++ b/t/08_plugin_various.t
|
||||||
|
@@ -19,6 +19,10 @@ subtest 'Bash completion' => sub {
|
||||||
|
like($bash_completion,qr/_test03_macc_somecommand\(\)\s\{/,'some_command present');
|
||||||
|
like($bash_completion,qr/--global_option/,'global_option present');
|
||||||
|
like($bash_completion,qr/--roleattr/,'roleattr present');
|
||||||
|
+ like($bash_completion,qr/_test03_macc_cmdwithsubcommands_subb/,'subcommand B present');
|
||||||
|
+ like($bash_completion,qr/_test03_macc_cmdwithsubcommands_subb/,'subcommand B present');
|
||||||
|
+ unlike($bash_completion,qr/_test03_macc_cmdwithsubcommands subb/,'subcommand B present');
|
||||||
|
+ unlike($bash_completion,qr/_test03_macc_cmdwithsubcommands subb/,'subcommand B present');
|
||||||
|
unlike($bash_completion,qr/bash_completion/,'bash_completion is not included');
|
||||||
|
};
|
||||||
|
|
||||||
|
diff --git a/t/testlib/Test03/CmdWithSubCommands/SubA.pm b/t/testlib/Test03/CmdWithSubCommands/SubA.pm
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..bf62c43
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/t/testlib/Test03/CmdWithSubCommands/SubA.pm
|
||||||
|
@@ -0,0 +1,14 @@
|
||||||
|
+package Test03::CmdWithSubCommands::SubA;
|
||||||
|
+
|
||||||
|
+use MooseX::App::Command;
|
||||||
|
+
|
||||||
|
+sub run {
|
||||||
|
+ my ($self) = @_;
|
||||||
|
+ use Data::Dumper;
|
||||||
|
+ {
|
||||||
|
+ local $Data::Dumper::Maxdepth = 2;
|
||||||
|
+ warn __FILE__.':line'.__LINE__.':'.Dumper($self);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+1;
|
||||||
|
diff --git a/t/testlib/Test03/CmdWithSubCommands/SubB.pm b/t/testlib/Test03/CmdWithSubCommands/SubB.pm
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..bb2678f
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/t/testlib/Test03/CmdWithSubCommands/SubB.pm
|
||||||
|
@@ -0,0 +1,14 @@
|
||||||
|
+package Test03::CmdWithSubCommands::SubB;
|
||||||
|
+
|
||||||
|
+use MooseX::App::Command;
|
||||||
|
+
|
||||||
|
+sub run {
|
||||||
|
+ my ($self) = @_;
|
||||||
|
+ use Data::Dumper;
|
||||||
|
+ {
|
||||||
|
+ local $Data::Dumper::Maxdepth = 2;
|
||||||
|
+ warn __FILE__.':line'.__LINE__.':'.Dumper($self);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+1;
|
12
README.md
Normal file
12
README.md
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
## Build Results
|
||||||
|
|
||||||
|
Current state of perl in openSUSE:Factory is
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
The current state of perl in the devel project build (devel:languages:perl)
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
|
@@ -7,8 +7,8 @@ description_paragraphs: 1
|
|||||||
#sources:
|
#sources:
|
||||||
# - source1
|
# - source1
|
||||||
# - source2
|
# - source2
|
||||||
#patches:
|
patches:
|
||||||
# bar.patch:
|
0001_fix_bashcompletion_with_subcommands.patch: -p1 PATCH-FIX-UPSTREAM M0ses https://github.com/maros/MooseX-App/issues/72
|
||||||
preamble: |-
|
preamble: |-
|
||||||
BuildRequires: perl(Config::Any)
|
BuildRequires: perl(Config::Any)
|
||||||
#post_prep: |-
|
#post_prep: |-
|
||||||
|
@@ -1,3 +1,10 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Fri Aug 9 18:26:30 UTC 2024 - Frank Schreiner <FSchreiner@suse.com>
|
||||||
|
|
||||||
|
- Add 0001_fix_bashcompletion_with_subcommands.patch
|
||||||
|
* Fixes: (#72) https://github.com/maros/MooseX-App/issues/72
|
||||||
|
* UPSTREAM PR: https://github.com/maros/MooseX-App/pull/73
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Fri Mar 8 22:44:05 UTC 2024 - Tina Müller <tina.mueller@suse.com>
|
Fri Mar 8 22:44:05 UTC 2024 - Tina Müller <tina.mueller@suse.com>
|
||||||
|
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
%define cpan_name MooseX-App
|
%define cpan_name MooseX-App
|
||||||
Name: perl-MooseX-App
|
Name: perl-MooseX-App
|
||||||
Version: 1.430.0
|
Version: 1.430.1
|
||||||
Release: 0
|
Release: 0
|
||||||
%define cpan_version 1.43
|
%define cpan_version 1.43
|
||||||
License: Artistic-1.0 OR GPL-1.0-or-later
|
License: Artistic-1.0 OR GPL-1.0-or-later
|
||||||
@@ -26,6 +26,9 @@ Summary: Write user-friendly command line apps with even less suffering
|
|||||||
URL: https://metacpan.org/release/%{cpan_name}
|
URL: https://metacpan.org/release/%{cpan_name}
|
||||||
Source0: https://cpan.metacpan.org/authors/id/M/MA/MAROS/%{cpan_name}-%{cpan_version}.tar.gz
|
Source0: https://cpan.metacpan.org/authors/id/M/MA/MAROS/%{cpan_name}-%{cpan_version}.tar.gz
|
||||||
Source1: cpanspec.yml
|
Source1: cpanspec.yml
|
||||||
|
Source100: README.md
|
||||||
|
# PATCH-FIX-UPSTREAM M0ses https://github.com/maros/MooseX-App/issues/72
|
||||||
|
Patch0: 0001_fix_bashcompletion_with_subcommands.patch
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
BuildRequires: perl
|
BuildRequires: perl
|
||||||
BuildRequires: perl-macros
|
BuildRequires: perl-macros
|
||||||
@@ -111,7 +114,7 @@ be defined as simple Moose accessors using the 'option' and 'parameter'
|
|||||||
keywords respectively.
|
keywords respectively.
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%autosetup -n %{cpan_name}-%{cpan_version}
|
%autosetup -n %{cpan_name}-%{cpan_version} -p 1
|
||||||
|
|
||||||
find . -type f ! -path "*/t/*" ! -name "*.pl" ! -path "*/bin/*" ! -path "*/script/*" ! -path "*/scripts/*" ! -name "configure" -print0 | xargs -0 chmod 644
|
find . -type f ! -path "*/t/*" ! -name "*.pl" ! -path "*/bin/*" ! -path "*/script/*" ! -path "*/scripts/*" ! -name "configure" -print0 | xargs -0 chmod 644
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user