MooseX:...texGroup(3)
πΈ NAME πΈ
MooseX::App::Plugin::MutexGroup β this little baddie (it's a plugin, section 3 of the User Contributed Perl Documentation, iykyk) adds mutually exclusive options to your app. Slay.
β¨ SYNOPSIS β¨
Okay so first, 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'
);
Then 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
Like, the vibes are: pick one chemical, bestie. Not both, not neither. π§ͺπ
π¦ DESCRIPTION π¦
This plugin adds mutually exclusive options to your application, and honestly? Iconic behaviour.
In the current implementation, every defined MutexGroup must have exactly one initialized option. Read that again, because it's the whole plot twist π β that means there's an implicit requiredness of one option from each MutexGroup.
So yeah: exactly one, always. No cap. π₯
π sign-off π
That's the whole page, bestie β brought to you by perl v5.42.0, dated 2024-08-09, and filed under MooseX:...texGroup(3). Go forth and pick exactly one option, mwah ππ
π¦ where this page comes from
- opensuse-leap 16.0: perl-MooseX-App 1.430.1-bp160.1.10 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms