MooseX:...Depends(3)
πΈ MooseX::App::Plugin::Depends πΈ
okay so bestie, you're looking at MooseX:...Depends(3) β the User Contributed Perl Documentation page for this plugin β and honestly? it's a whole vibe. it adds dependent options. that's the tea. π
β¨ NAME β¨
MooseX::App::Plugin::Depends β literally just adds dependent options. that's it, that's the plugin. π
π¦ SYNOPSIS π¦
okay so picture this: you're in your base class, right? and this is what you write:
package MyApp;
use MooseX::App qw(Depends);
use Moose::Util::TypeConstraints;
option 'FileFormat' => (
is => 'ro',
isa => enum( [qw(tsv csv xml)] ),
);
option 'WriteToFile' => (
is => 'ro',
isa => 'Bool',
depends => [qw(FileFormat)],
);
see that depends => [qw(FileFormat)]? yeah. that's the main character right there. π
now over in your script, bestie, it goes like this:
#!/usr/bin/env perl
use strict;
use warnings;
use MyApp;
MyApp->new_with_options( WriteToFile => 1 );
# generates Error
# Option 'WriteToFile' requires 'FileFormat' to be defined
MyApp->new_with_options( WriteToFile => 1, FileFormat => 'tsv );
# generates no errors
MyApp->new_with_options();
# generates no errors
so like β first call? π error. it's giving Option 'WriteToFile' requires 'FileFormat' to be defined. you asked for the file but you never told it what format, and the app is not about to guess.
second call? you gave it both, 'tsv' and all, and it's π no errors. slay.
third call? you gave it nothing and it's still no errors. iconic behaviour, honestly. doing nothing is always valid. β¨
π DESCRIPTION π
okay so real talk: in like, many real-world scenarios (not me being all professional π), sets of options are, by design, needed to be specified together. like, they're a package deal. they come as a set. you can't split them up.
this plugin adds the ability to create dependent options to your application β options that require one or more other options for your application to perform properly. π«Ά
so if option A says it depends on option B, and you show up with A but no B? the app will look at you, and it will error. respectfully. π§
the vibe check: the plugin isn't magic β it just adds the ability to declare that one option needs one or more others before the app can do its thing properly. that's the whole feature. and honestly? obsessed.
and that's the page, bestie π no cap, every flag, every snippet, every little detail is right here β you're welcome.
π this little number is from perl v5.42.0, dated 2024-08-09, and it's the MooseX:...Depends(3) page β catch you in the next manpage, 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