BioSAILs

 view release on metacpan or  search on metacpan

lib/BioSAILs/Utils/LoadConfigs.pm  view on Meta::CPAN

package BioSAILs::Utils::LoadConfigs;

use 5.010;
use utf8;

use namespace::autoclean;
use MooseX::App::Role;

use Config::Any;
use File::HomeDir;
use Cwd;
use MooseX::Types::Path::Tiny qw/Path Paths AbsPaths AbsFile/;
use Path::Tiny;
use Try::Tiny;
use Hash::Merge qw( merge );

option 'no_configs' => (
    is            => 'rw',
    isa           => 'Bool',
    default       => 0,
    documentation => '--no_configs tells HPC::Runner not to load any configs',
);

option 'config' => (
    isa           => 'Str',
    is            => 'rw',
    required      => 0,
    documentation => 'Override the search paths and supply your own config.',
    isa           => AbsFile,
    coerce        => 1,
    predicate     => 'has_config',
);

option 'config_base' => (
    is            => 'rw',
    isa           => 'Str',
    default       => '.config',
    documentation => 'Basename of config files',
);

option 'search' => (
    traits  => ['Bool'],
    is      => 'rw',
    isa     => 'Bool',
    default => 1,
    handles => {
        'no_search' => 'unset',
    },
    documentation =>
'Search for config files in ~/.config.(ext) and in your current working directory.'
);

option 'search_path' => (
    traits  => ['Array'],
    is      => 'rw',
    isa     => 'ArrayRef[Str]',
    default => sub { [ File::HomeDir->my_home, getcwd() ] },
    handles => {
        all_search_path     => 'elements',
        append_search_path  => 'push',
        prepend_search_path => 'unshift',
        map_search_path     => 'map',
        has_search_path     => 'count',
    },
    documentation =>
      'Enable a search path for configs. Default is the home dir and your cwd.'
);

has 'filter_keys' => (
    is      => 'rw',
    traits  => ['Array'],
    is      => 'rw',
    isa     => 'ArrayRef[Str]',
    default => sub { [] },



( run in 1.311 second using v1.01-cache-2.11-cpan-39bf76dae61 )