1MooseX::App::Plugin::DeUpseenrdsC(o3n)tributed Perl DocuMmoeonsteaXt:i:oAnpp::Plugin::Depends(3)
2
3
4

NAME

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

SYNOPSIS

9       In your base class:
10
11        package MyApp;
12        use MooseX::App qw(Depends);
13
14        use Moose::Util::TypeConstraints;
15
16        option 'FileFormat' => (
17          is  => 'ro',
18          isa => enum( [qw(tsv csv xml)] ),
19        );
20
21        option 'WriteToFile' => (
22          is       => 'ro',
23          isa      => 'Bool',
24          depends => [qw(FileFormat)],
25        );
26
27       In your script:
28
29        #!/usr/bin/env perl
30
31        use strict;
32        use warnings;
33
34        use MyApp;
35
36        MyApp->new_with_options( WriteToFile => 1 );
37        # generates Error
38        # Option 'WriteToFile' requires 'FileFormat' to be defined
39
40        MyApp->new_with_options( WriteToFile => 1, FileFormat => 'tsv );
41        # generates no errors
42
43        MyApp->new_with_options();
44        # generates no errors
45

DESCRIPTION

47       In many real-world scenarios, sets of options are, by design, needed to
48       be specified together. This plugin adds the ability to create dependent
49       options to your application, options that require one or more other
50       options for your application to perform properly.
51
52
53
54perl v5.30.1                      2020-01-30   MooseX::App::Plugin::Depends(3)
Impressum