Subject: | CLI::Dispatch::Help searches too deep |
Hi,
Thanks for writing CLI::Dispatch. I've run across a small problem with
CLI::Dispatch::Help::list_commands.
I'm attempting to create "sub" commands, as in:
bin/x b c
where c is a subcommand for b. This is working quite well, actually.
Below is a layout of the code (hopefully this survives reformatting)
.
├── bin
│ └── x
└── lib
├── X
│ ├── A.pm
│ ├── B
│ │ ├── X
│ │ │ └── C.pm
│ │ └── X.pm
│ └── B.pm
└── X.pm
and B.pm is a mix of a command and a top level dispatcher:
package X::B;
use CLI::Dispatch;
use base 'CLI::Dispatch::Command';
use X::B::X;
sub run {
X::B::X->run;
}
1;
The only problem that I've come across so far is that
CLI::Dispatch::Help::list_commands searches deep into the namespaces,
and finds the sub-commands when I believe it shouldn't, with odd results:
% bin/x
a - x::a
b - x::b
c - [disabled: compile error]
help - show help
x - [disabled: compile error]
It's finding X::B::X.pm and X::B::X::C.pm when it shouldn't. X::B::X.pm
isn't a command at all, and X::B::X::C.pm is b's c command. I expected
something like this:
% bin/x
a - x::a
b - x::b
help - show help
With help for b's subcommands available when I run
% bin/x b
c - x b x c
help - show help
(that does work fine).
It doesn't look like CLI::Dispatch::Help is performing the deep search
for any real reason; it's not attempting to build a list of sub commands
(as %found is keyed off of the basename of the module, not the relative
path to the top of the namespace).
Is the deep search necessary? I realize that what I'm doing isn't using
the documented behavior, but the implementations of sub-commands is so
straightforward that it'd be a shame not to be able to use it.
Thanks,
Diab
P.S. I've attached a zip file of the example code.
Subject: | cli-dispatch.zip |
Message body not shown because it is not plain text.