App-DuckPAN

 view release on metacpan or  search on metacpan

lib/App/DuckPAN/Cmd/New.pm  view on Meta::CPAN

package App::DuckPAN::Cmd::New;
our $AUTHORITY = 'cpan:DDG';
# ABSTRACT: Take a name as input and generates a new, named Goodie or Spice instant answer skeleton
$App::DuckPAN::Cmd::New::VERSION = '1021';
# See the template/templates.yml file in the Goodie or Spice repository for the
# list of template-sets and files generated for them

use Moo;
with qw( App::DuckPAN::Cmd );

use MooX::Options protect_argv => 0;
use Try::Tiny;
use List::MoreUtils 'any';

use App::DuckPAN::TemplateDefinitions;

no warnings 'uninitialized';
##########################
# Command line arguments #
##########################

# A 'template' for the user is equivalent to a 'template-set' for the program
option template => (
	is      => 'rwp',
	format  => 's',
	default => 'default',
	short   => 't',
	doc     => 'template used to generate the instant answer skeleton (default: default)',
);

option list_templates => (
	is    => 'ro',
	short => 'l',
	doc   => 'list the available instant answer templates and exit',
);

option cheatsheet => (
	is    => 'ro',
	short => 'c',
	doc   => "create a Cheat Sheet (short for `--template cheatsheet'; valid only for Goodies)",
);

option no_optionals => (
	is  => 'ro',
	short => 'N',
	doc => 'do not create any optional files from the chosen template',
);

##############
# Attributes #
##############

has _template_defs => (
	is       => 'ro',
	init_arg => undef,
	lazy     => 1,
	builder  => 1,
	doc      => 'Template definitions for the templates for the current IA type',
);

sub _build__template_defs {
	my $self = shift;
	my $template_defs;

	# Read the templates.yml file
	try {
		$template_defs = App::DuckPAN::TemplateDefinitions->new;
	} catch {
		my $error = $_;

		if ($error =~ /no such file/i) {
			# Handle the 'no such file or directory' exception



( run in 2.731 seconds using v1.01-cache-2.11-cpan-98e64b0badf )