in reply to Re: Moo and command line scripts
in thread Moo and command line scripts

Thanks, I'll take a look at that. I'm not completely comfortable with the environment variable myself but all of my tests seem to show it works properly.

You must always remember that the primary goal is to drain the swamp even when you are hip-deep in alligators.

Replies are listed 'Best First'.
Re^3: Moo and command line scripts
by tobyink (Canon) on Nov 11, 2019 at 08:42 UTC

    Yeah, it only becomes an issue if you're loading two classes that consume MooX::Role::CliOptions, and they each want different settings for the environment variable. None of your tests do that.

    use 5.006; use strict; use warnings; use Test::More; { package My::Class1; use Moo; $ENV{MRC_NO_STDOPTS} = 1; # do NOT want 'debug' and 'verbose' with 'MooX::Role::CliOptions'; } { package My::Class2; use Moo; $ENV{MRC_NO_STDOPTS} = 0; # do want 'debug' and 'verbose' with 'MooX::Role::CliOptions'; } ok( ! My::Class1->new->can('verbose') ); ok( My::Class2->new->can('verbose') ); done_testing;