| 1 | =head1 NAME | ||
| 2 | |||
| 3 | CLIPSeqTools::Role::Option::OutputPrefix - Role to enable output prefix as command line option. | ||
| 4 | |||
| 5 | =head1 SYNOPSIS | ||
| 6 | |||
| 7 | Role to enable output prefix as command line option. | ||
| 8 | |||
| 9 | Defines options. | ||
| 10 | -o_prefix <Str> output path prefix. If path does not exist it will be created. Default: ./ | ||
| 11 | |||
| 12 | Provides methods. | ||
| 13 | make_path_for_output_prefix creates the path for the output prefix if it does not exist. eg foo/bar.txt will create foo/ | ||
| 14 | |||
| 15 | =cut | ||
| 16 | |||
| 17 | |||
| 18 | package CLIPSeqTools::Role::Option::OutputPrefix; | ||
| 19 | $CLIPSeqTools::Role::Option::OutputPrefix::VERSION = '1.0.0'; | ||
| 20 | |||
| 21 | ####################################################################### | ||
| 22 | ####################### Load External modules ##################### | ||
| 23 | ####################################################################### | ||
| 24 | use Modern::Perl; | ||
| 25 | use MooseX::App::Role; | ||
| 26 | use File::Path qw(make_path); | ||
| 27 | use File::Spec; | ||
| 28 | |||
| 29 | |||
| 30 | ####################################################################### | ||
| 31 | ####################### Command line options ###################### | ||
| 32 | ####################################################################### | ||
| 33 | option 'o_prefix' => ( | ||
| 34 | is => 'rw', | ||
| 35 | isa => 'Str', | ||
| 36 | default => './', | ||
| 37 | documentation => 'output path prefix. Program will add an extension to prefix. If path does not exist it will be created.', | ||
| 38 | ); | ||
| 39 | |||
| 40 | |||
| 41 | ####################################################################### | ||
| 42 | ######################## Interface Methods ######################## | ||
| 43 | ####################################################################### | ||
| 44 | sub make_path_for_output_prefix { | ||
| 45 | my ($self) = @_; | ||
| 46 | |||
| 47 | my (undef, $directory, undef) = File::Spec->splitpath($self->o_prefix); | ||
| 48 | make_path($directory); | ||
| 49 | } | ||
| 50 | |||
| 51 | sub validate_args {} | ||
| 52 | |||
| 53 | |||
| 54 | 1; |