1MooseX::App::Plugin::MuUtseexrGrCoounpt(r3i)buted Perl DMoocousmeeXn:t:aAtpipo:n:Plugin::MutexGroup(3)
2
3
4

NAME

6       MooseX::App::Plugin::MutexGroup - Adds mutually exclusive options
7

SYNOPSIS

9       In your base class:
10
11        package MyApp;
12        use MooseX::App qw(MutexGroup);
13
14        option 'UseAmmonia' => (
15          is         => 'ro',
16          isa        => 'Bool',
17          mutexgroup => 'NonMixableCleaningChemicals',
18        );
19
20        option 'UseChlorine' => (
21          is         => 'ro',
22          isa        => 'Bool',
23          mutexgroup => 'NonMixableCleaningChemicals'
24        );
25
26       In your script:
27
28        #!/usr/bin/env perl
29
30        use strict;
31        use warnings;
32
33        use MyApp;
34
35        MyApp->new_with_options( UseAmmonia => 1, UseChlorine => 1 );
36        # generates Error
37        # More than one attribute from mutexgroup NonMixableCleaningChemicals('UseAmmonia','UseChlorine') *cannot* be specified
38
39        MyApp->new_with_options();
40        # generates Error
41        # One attribute from mutexgroup NonMixableCleaningChemicals('UseAmmonia','UseChlorine') *must* be specified
42
43        MyApp->new_with_options( UseAmmonia => 1 );
44        # generates no errors
45
46        MyApp->new_with_options( UseChlorine => 1 );
47        # generates no errors
48

DESCRIPTION

50       This plugin adds mutually exclusive options to your application. In the
51       current implementation, all defined MutexGroups *must* have exactly one
52       initialized option. This means that there is an implicit requiredness
53       of one option from each MutexGroup.
54
55
56
57perl v5.30.1                      2020-01-30MooseX::App::Plugin::MutexGroup(3)
Impressum