/usr/share/perl5/MooseX/App/Plugin/Config/Meta/Class.pm is in libmoosex-app-perl 1.33-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | # ============================================================================
package MooseX::App::Plugin::Config::Meta::Class;
# ============================================================================
use 5.010;
use utf8;
use namespace::autoclean;
use Moose::Role;
around 'command_proto' => sub {
my ($orig,$self,$metaclass) = @_;
my ($result,$errors) = $self->$orig($metaclass);
delete $result->{config}
unless defined $result->{config};
return $self->proto_config($metaclass,$result,$errors);
};
sub proto_config {
my ($self,$metaclass,$result,$errors) = @_;
# Check if we have a config
return ($result,$errors)
unless defined $result->{config};
# Read config
my $config_file = Path::Class::File->new($result->{config});
unless (-e $config_file->stringify) {
push(@{$errors},
$self->command_message(
header => "Could not find config file '".$config_file->stringify."'",
type => "error",
),
);
return ($result,$errors);
}
my $config_file_name = $config_file->stringify;
my $configs = Config::Any->load_files({
files => [ $config_file_name ],
use_ext => 1,
});
my $command_name = $self->command_class_to_command($metaclass->name);
my ($config_data) = values %{$configs->[0]};
# Merge
$config_data->{global} ||= {};
$config_data->{$command_name} ||= {};
# Set config data
$result->{config} = $result->{config};
$result->{_config_data} = $config_data;
# Lopp all attributes
foreach my $attribute ($self->command_usage_attributes($metaclass,'all')) {
my $attribute_name = $attribute->name;
next
if $attribute_name eq 'config' || $attribute_name eq 'help_flag';
$result->{$attribute_name} = $config_data->{global}{$attribute_name}
if defined $config_data->{global}{$attribute_name};
$result->{$attribute_name} = $config_data->{$command_name}{$attribute_name}
if defined $config_data->{$command_name}{$attribute_name};
}
return ($result,$errors);
};
1;
|