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

Default commands #12

Closed
wants to merge 13 commits into
base: master
from

Conversation

Projects
None yet
2 participants
@jjatria

jjatria commented Aug 14, 2017

This patch is branched off of 6d3c444, which is in PR #10.

It implements default commands for commands, help, and version, and adds a test app Test::MyCmd, ported from App::Cmd, to illustrate their use.

This test app can later be used to expand the test suite.

jjatria added some commits Aug 11, 2017

Make cmd_map map to possibly arbitrary packages
This patch modifies the behaviour of cmd_map to always return
the full name of the package implementing a given command, or
return undef trying.

Aliases that map to a string starting with a '+' sign are returned
as-is, mimicking the behaviour in other distributions. This makes
it possible to accept common commands (like 'help' or 'version') and
pass them to existing packages that can be extended by other users.
Add Usage class, outsourcing POD munging to Pod::Usage
Until now, the usage commands parsed the POD of a specified file
manually opening a filehandle and using Pod::Simple::Text. This was
done everywhere that required parsing the POD, which included the
default Help command, as well as the usage and brief_usage functions.

This commit implements a App::CLI::Usage class that is simply a wrapper
around Pod::Usage (or whatever other POD parser is passed as argument).
Add usage_desc as an attribute of commands
The usage_desc attribute, inspired by that of App::Cmd,
will be used to give the user some high-level customisation
when generating brief usage messages.

This will be done with String::Format, emulating the behaviour
of App::Cmd.
Make commands() optionally include aliases
Although 08d620b makes commands()
return the list of commands, including any aliases, it can be useful
to have a distinction between proper commands, and _all_ commands.

This patch enables both behaviours by keeping the plain function
call as returning only the command names (keeping the old interface),
and requiring a true argument to be passed in order to include any
aliases.
Add Test::MyCmd test app, modeled after App::Cmd
This patch adds a port of the Test::MyCmd test app present in the
App::Cmd distribution. This serves to illustrate a way in which
equivalent behaviour can be implemented in both distributions, which
can help users make a choice between the two, and also makes it
easier to use the test suite from App::Cmd as a baseline for testing
App::CLI.
@paultcochrane

This comment has been minimized.

Show comment
Hide comment
@paultcochrane

paultcochrane Nov 1, 2017

Owner

Hi @jjatria. I've merged most of your commits, unfortunately the ones concerning the usage changes couldn't be merged since they would break downstream code (see, for example, the biggest customer SVK). I like the changes, and spent quite a while trying to merge them, however they'll break other people's code, so I've had to avoid merging them. If you'd like to have your usage changes added to this dist, please modify them so that they pass the current test suite on master (I've extended the coverage to try to cover current behaviour as best as possible).

Many thanks again for your patches!

Owner

paultcochrane commented Nov 1, 2017

Hi @jjatria. I've merged most of your commits, unfortunately the ones concerning the usage changes couldn't be merged since they would break downstream code (see, for example, the biggest customer SVK). I like the changes, and spent quite a while trying to merge them, however they'll break other people's code, so I've had to avoid merging them. If you'd like to have your usage changes added to this dist, please modify them so that they pass the current test suite on master (I've extended the coverage to try to cover current behaviour as best as possible).

Many thanks again for your patches!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment