diff --git a/lib/Mojolicious/Commands.pm b/lib/Mojolicious/Commands.pm index 22935931be..a95d542fdb 100644 --- a/lib/Mojolicious/Commands.pm +++ b/lib/Mojolicious/Commands.pm @@ -65,8 +65,10 @@ sub run { # Find all available commands my %all; for my $ns (@{$self->namespaces}) { - $all{substr $_, length "${ns}::"} //= $_->new->description - for grep { _command($_) } find_modules($ns), find_packages($ns); + for my $pkg (find_modules($ns), find_packages($ns)) { + next unless _command($pkg); + $all{substr $pkg, length "${ns}::"} //= $pkg->new->description + } } my @rows; @@ -323,3 +325,4 @@ C<--home> and C<-m>/C<--mode>, which are shared by all commands, will be parsed L, L, L. =cut +