File: ConfigFromFile.pm

package info (click to toggle)
libmoox-cmd-perl 0.017-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 320 kB
  • sloc: perl: 1,110; sh: 6; makefile: 2
file content (43 lines) | stat: -rw-r--r-- 955 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package MooX::Cmd::Role::ConfigFromFile;

use strict;
use warnings;

our $VERSION = "0.017";

use Moo::Role;

=head1 NAME

MooX::Cmd::Role::ConfigFromFile - MooX::ConfigFromFile support role for MooX::Cmd

=cut

requires "config_prefixes";

around _build_config_prefixes => sub {
    my $next     = shift;
    my $class    = shift;
    my $params   = shift;
    my $cfg_pfxs = $class->$next($params, @_);

    ref $params->{command_chain} eq "ARRAY"
      and push @{$cfg_pfxs},
      grep { defined $_ } map { $_->command_name } grep { $_->can("command_name") } @{$params->{command_chain}};

    return $cfg_pfxs;
};

=head1 LICENSE AND COPYRIGHT

Copyright 2015-2017 Jens Rehsack.

This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.

See L<http://dev.perl.org/licenses/> for more information.

=cut

1;