NAME
App::Scaffolder::Command - Base class for App::Scaffolder commands
VERSION
version 0.002000
SYNOPSIS
package App::Scaffolder::Command::mycommand;
use parent qw(App::Scaffolder::Command);
sub get_dist_name {
return 'App-Scaffolder-MyDist';
}
1;
DESCRIPTION
App::Scaffolder::Command is a base class for App::Scaffolder commands. Among other things, it provides access to the templates that belong to the command and provides the execute
method which handles some basic parameters like --list
and also evaluates the selected template.
contains_base_args
Check if options contain a base argument like --list
or --create-template-dir
.
Result
True if yes, false otherwise.
get_options
Getter for the options. Should be implemented by subclasses.
Result
A list with additional options for the command.
get_template_dirs
Getter for the directories where templates are searched. Uses File::HomeDir and File::ShareDir using the distribution name and appends the command name to the directory. If get_extra_template_dirs
returns a non-empty list, this will be put between these two default directories.
Result
A list with the directories.
get_extra_template_dirs
Method to insert additional template directories between the 'local', File::HomeDir-based directory and the 'global', File::ShareDir-based one into the search path. By default, this takes the directories from the SCAFFOLDER_TEMPLATE_PATH
environment variable.
Parameters
This method expects positional parameters.
- command
-
Name of the command template directories should be returned for.
Result
A potentially empty list with the additional directories.
get_templates
Reads the template directories and creates a App::Scaffolder::Template object for each template that is found.
Result
A hash reference with the found templates.
get_template
Get the template with a given name.
Parameters
This method expects positional parameters.
- name
-
Name of the template.
Result
The App::Scaffolder::Template with the given name if it exists, an exception otherwise.
get_target
Extract the target directory from the options.
Parameters
This method expects positional parameters.
- opt
-
Options as passed to
execute
.
Result
A Path::Class::Dir object with the target directory.
get_variables
Get variables that should be passed to templates. Should be overridden by subclasses.
Result
A hash reference with template variables.
get_dist_name
Getter for the distribution name. Must be implemented by subclasses.
Result
The name of the distribution the command belongs to.
execute
Execute the command using the given command line options.
Result
Nothing on success, an exception otherwise.
AUTHOR
Manfred Stock <mstock@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by Manfred Stock.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.