Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: How can I configure the perl App::Cmd module to complain about incorrect options

by tobyink (Abbot)
on Jun 17, 2013 at 15:54 UTC ( #1039405=note: print w/ replies, xml ) Need Help??


in reply to How can I configure the perl App::Cmd module to complain about incorrect options

If you pass an unrecognised option, App::Cmd doesn't complain, but it also doesn't ignore it! It adds it to the $args array.

If you don't like this, the easiest thing is to create a subclass of App::Cmd::Command, and override validate_args to check for arguments that look like they were intended to be options. Then use your subclass instead of using App::Cmd::Command directly.

package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name


Comment on Re: How can I configure the perl App::Cmd module to complain about incorrect options
Select or Download Code
Re^2: How can I configure the perl App::Cmd module to complain about incorrect options
by ascobie (Initiate) on Jun 18, 2013 at 08:50 UTC
    Great, thanks!

    Will give that a go.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1039405]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2014-08-29 01:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (275 votes), past polls