BioX-Workflow-Command
view release on metacpan or search on metacpan
lib/BioX/Workflow/Command/Utils/Files.pm view on Meta::CPAN
package BioX::Workflow::Command::Utils::Files;
use MooseX::App::Role;
use namespace::autoclean;
use MooseX::Types::Path::Tiny qw/AbsFile/;
use File::Basename;
use DateTime;
use Try::Tiny;
use Config::Any;
use File::Spec;
option 'workflow' => (
is => 'rw',
isa => AbsFile,
required => 1,
coerce => 1,
documentation => 'Supply a workflow',
cmd_aliases => ['w'],
);
=head3 workflow_data
initial config file read into a perl structure
=cut
has 'workflow_data' => (
is => 'rw',
isa => 'HashRef',
default => sub { return {} },
);
option 'outfile' => (
is => 'rw',
isa => 'Str',
lazy => 1,
default => sub {
my $self = shift;
my $workflow = $self->workflow;
my @files = fileparse( $self->workflow, qr/\.[^.]*/ );
my $dt = DateTime->now( time_zone => 'local' );
my $file_name =
$files[0] . '_' . $dt->ymd . '_' . $dt->time('-') . '.sh';
return File::Spec->rel2abs( $file_name );
},
documentation => 'Write your workflow to a file',
cmd_aliases => ['o'],
);
option 'stdout' => (
is => 'rw',
isa => 'Bool',
default => 0,
documentation => 'Write workflows to STDOUT',
predicate => 'has_stdout',
);
has 'fh' => (
is => 'rw',
lazy => 1,
default => sub {
my $self = shift;
my $fh = new IO::File;
if ( $self->stdout ) {
$fh->fdopen( fileno(STDOUT), "w" );
}
else {
$fh->open( "> " . $self->outfile );
( run in 0.683 second using v1.01-cache-2.11-cpan-39bf76dae61 )