package BioX::Workflow::Command;

use v5.10;
our $VERSION = '2.0.5';

use MooseX::App qw(Color);
use MooseX::Types::Path::Tiny qw/Path/;
use Cwd qw(getcwd);
use File::Spec;
use File::Path qw(make_path);

app_strict 0;

# TODO move this after I have a better idea of where it is going
option 'cache_dir' => (
    is      => 'rw',
    isa     => Path,
    coerce  => 1,
    default => sub {
        return File::Spec->catfile( getcwd(), '.biox-cache' );
    },
    documentation =>
      'BioX-Workflow will cache some information during your runs. '
      . 'Delete with caution! '
      . '[Default: '.getcwd().'/biox-cache. ]'
);

sub BUILD {
  my $self = shift;
}

before 'BUILD' => sub {
    my $self = shift;

    make_path( $self->cache_dir );
    make_path(File::Spec->catdir($self->cache_dir, 'logs'));
};

no Moose;
__PACKAGE__->meta->make_immutable;

1;

__END__

=encoding utf-8

=head1 NAME

BioX::Workflow::Command - Opinionated Bioinformatics Genomics Workflow Creator

=head1 SYNOPSIS

  biox run -w workflow.yml

=head1 documentation

Full documentation is available at gitbooks. L<Documentation | https://biosails.gitbooks.io/biox-workflow-command-docs/content/>

=head1 Quick Start

=head2 Get Help

  #Global Help
  biox --help
  biox-workflow.pl --help
  #Help Per Command
  biox run --help

=head2 Run a Workflow

  #Previously biox-workflow.pl --workflow workflow.yaml
  biox run -w workflow.yml #or --workflow
  biox-workflow.pl run --workflow workflow.yml

=head2 Run a Workflow with make like utilities

Using the option --use_timestamps will select only rules that have INPUT/OUTPUT that does not exist or has been modified since the last log.

  biox run --workflow workflow.yml --use_timestamps

Using the option --auto_deps will create #HPC deps based on your INPUT/OUTPUTs - use this with caution. It will only work correctly if INPUT/OUTPUT is complete and accurate.

  biox run --workflow workflow.yml --auto_deps

Option --make enables both --use_timestamps and --auto_deps

  biox run --workflow workflow.yml --make

=head2 Create a new workflow

This creates a new workflow with rules rule1, rule2, rule3, with a few variables to help get you started.

  biox new -w workflow.yml --rules rule1,rule2,rule3

=head2 Add a new rule to a workflow

Add new rules to an existing workflow.

  biox add -w workflow.yml --rules rule4

=head2 Check the status of files in your workflow

You must have defined INPUT/OUTPUTs to make use of this rule. If you do, biox will output a table with information about your files.

  biox stats -w workflow.yml

=head1 DESCRIPTION

BioX::Workflow::Command is a templating system for creating Bioinformatics Workflows.

=head1 AUTHOR

Jillian Rowe E<lt>jillian.e.rowe@gmail.comE<gt>

=head1 COPYRIGHT

Copyright 2017- Jillian Rowe

=head1 LICENSE

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

=head1 Acknowledgements

As of version 0.03:

This modules continuing development is supported
by NYU Abu Dhabi in the Center for Genomics and
Systems Biology. With approval from NYUAD, this
information was generalized and put on github,
for which the authors would like to express their
gratitude.

Before version 0.03

This module was originally developed at and for Weill Cornell Medical
College in Qatar within ITS Advanced Computing Team. With approval from
WCMC-Q, this information was generalized and put on github, for which
the authors would like to express their gratitude.


=head1 SEE ALSO

=cut
