MooseX::App::Plugin::MutexGroup(3pm)

MooseX::App::Plugin::MutexGroup3pm

Adds mutually exclusive options

Usage

In your base class:

 package MyApp;
 use MooseX::App qw(MutexGroup);
 
 option 'UseAmmonia' => (
   is         => 'ro',
   isa        => 'Bool',
   mutexgroup => 'NonMixableCleaningChemicals',
 );
 
 option 'UseChlorine' => (
   is         => 'ro',
   isa        => 'Bool',
   mutexgroup => 'NonMixableCleaningChemicals'
 );

In your script:

 #!/usr/bin/env perl
 
 use strict;
 use warnings;
 
 use MyApp;
 
 MyApp->new_with_options( UseAmmonia => 1, UseChlorine => 1 );
 # generates Error
 # More than one attribute from mutexgroup NonMixableCleaningChemicals('UseAmmonia','UseChlorine') *cannot* be specified
 
 MyApp->new_with_options();
 # generates Error
 # One attribute from mutexgroup NonMixableCleaningChemicals('UseAmmonia','UseChlorine') *must* be specified
 
 MyApp->new_with_options( UseAmmonia => 1 );
 # generates no errors
 
 MyApp->new_with_options( UseChlorine => 1 );
 # generates no errors

Overview

This plugin adds mutually exclusive options to your application. In the current implementation, all defined MutexGroups *must* have exactly one initialized option. This means that there is an implicit requiredness of one option from each MutexGroup.

Releases

5 releases since Debian 9 (Stretch); the text changed 4 times.

  1. 9
  2. 10
  3. 11
  4. 12
  5. 13

From libmoosex-app-perl 1.43-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.