GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
MooseX::App::Plugin::Depends(3) User Contributed Perl Documentation MooseX::App::Plugin::Depends(3)

MooseX::App::Plugin::Depends - Adds dependent options

In your base class:

 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)],
 );

In your script:

 #!/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

In many real-world scenarios, sets of options are, by design, needed to be specified together. 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.
2021-08-15 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.