Dist-Zilla-BeLike-CSJEWELL

changeset 2:0d3040ae67a1

Add configuration command.
author Curtis Jewell <csjewell@cpan.org>
date Wed Aug 11 23:16:55 2010 -0600 (2010-08-11)
parents 3ef3255e3fdf
children a977f0b89982
files Build.PL lib/Dist/Zilla/App/Command/configure_CSJEWELL.pm lib/Dist/Zilla/CSJEWELL.pm
line diff
     1.1 --- a/Build.PL	Wed Aug 11 23:15:51 2010 -0600
     1.2 +++ b/Build.PL	Wed Aug 11 23:16:55 2010 -0600
     1.3 @@ -67,6 +67,7 @@
     1.4          'Dist::Zilla::Plugin::Twitter'        => '0.009',
     1.5  		'Module::Build'                       => '0.33',
     1.6  		'Moose'                               => '1.09',
     1.7 +		'autodie'                             => '2.70',
     1.8  		# These are what the author tests require.
     1.9  		# Might as well have the prospective builder install
    1.10  		#  them now.
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/lib/Dist/Zilla/App/Command/configure_CSJEWELL.pm	Wed Aug 11 23:16:55 2010 -0600
     2.3 @@ -0,0 +1,140 @@
     2.4 +package Dist::Zilla::App::Command::configure_CSJEWELL;
     2.5 +
     2.6 +use 5.008003;
     2.7 +use strict;
     2.8 +use warnings;
     2.9 +use Dist::Zilla::App -command;
    2.10 +use autodie;
    2.11 +use File::Spec;
    2.12 +
    2.13 +our $VERSION = '0.900';
    2.14 +$VERSION =~ s/_//sm;
    2.15 +
    2.16 +sub abstract { ## no critic(ProhibitAmbiguousNames)
    2.17 +	return q{configure the 'CSJEWELL' minting profile.};
    2.18 +}
    2.19 +
    2.20 +sub validate_args {
    2.21 +	my ( $self, undef, $args ) = @_;
    2.22 +
    2.23 +	if ( 0 != @{$args} ) {
    2.24 +		$self->usage_error('Too many arguments');
    2.25 +	}
    2.26 +
    2.27 +	return;
    2.28 +}
    2.29 +
    2.30 +sub execute {
    2.31 +	my ( $self, undef, undef ) = @_;
    2.32 +
    2.33 +	my $chrome = $self->app()->chrome();
    2.34 +
    2.35 +	## no critic(ProtectPrivateSubs)
    2.36 +	my $config_root = Dist::Zilla::Util->_global_config_root();
    2.37 +
    2.38 +	if (   not -d $config_root
    2.39 +		or not -f File::Spec->catfile( $config_root, 'config.ini' ) )
    2.40 +	{
    2.41 +		$chrome->logger()->log_fatal( [
    2.42 +				'A per-user configuration file does not exist in %s',
    2.43 +				"$config_root",
    2.44 +			] );
    2.45 +
    2.46 +		return;
    2.47 +	}
    2.48 +
    2.49 +	my $homepage = $chrome->prompt_str(
    2.50 +		'Where is your homepage?',
    2.51 +		{   check => sub { defined $_[0] and $_[0] =~ /\S/ms },
    2.52 +			default => 'http://search.cpan.org/~username/',
    2.53 +		},
    2.54 +	);
    2.55 +
    2.56 +	my $repo = $chrome->prompt_str(
    2.57 +		'Where are your repositories?',
    2.58 +		{   check => sub { defined $_[0] and $_[0] =~ /\S/ms },
    2.59 +			default => 'http://bitbucket.org/username/',
    2.60 +		},
    2.61 +	);
    2.62 +
    2.63 +	open my $fh, '>>', $config_root->file('config.ini');
    2.64 +
    2.65 +	$fh->print("\n[%DefaultURLs]\n");
    2.66 +	$fh->print("homepage            = $homepage\n");
    2.67 +	$fh->print("repository_location = $repo\n\n");
    2.68 +
    2.69 +	close $fh;
    2.70 +
    2.71 +	$self->log('Added to config.ini file.');
    2.72 +
    2.73 +	return;
    2.74 +} ## end sub execute
    2.75 +
    2.76 +1;
    2.77 +
    2.78 +__END__
    2.79 +
    2.80 +=pod
    2.81 +
    2.82 +=head1 NAME
    2.83 +
    2.84 +Dist::Zilla::App::Command::configure_CSJEWELL - set up the global config file
    2.85 +
    2.86 +=head1 VERSION
    2.87 +
    2.88 +This document describes Dist::Zilla::App::Command::configure_CSJEWELL version 0.900.
    2.89 +
    2.90 +=head1 SYNOPSIS
    2.91 +
    2.92 +  C:\> dzil configure_CSJEWELL
    2.93 +
    2.94 +This command prompts the user for information that is used in the CSJEWELL 
    2.95 +minting profile and stores it in F<config.ini>.
    2.96 +
    2.97 +=for Pod::Coverage abstract validate_args execute 
    2.98 +
    2.99 +=head1 AUTHOR
   2.100 +
   2.101 +Curtis Jewell <CSJewell@cpan.org>
   2.102 +
   2.103 +=head1 SEE ALSO
   2.104 +
   2.105 +L<Dist::Zilla::CSJEWELL|Dist::Zilla::CSJEWELL>
   2.106 +
   2.107 +=head1 LICENSE AND COPYRIGHT
   2.108 +
   2.109 +Copyright (c) 2010, Curtis Jewell C<< CSJewell@cpan.org >>.
   2.110 +
   2.111 +This module is free software; you can redistribute it and/or
   2.112 +modify it under the same terms as Perl itself, either version
   2.113 +5.8.1 or any later version. See L<perlartistic|perlartistic> 
   2.114 +and L<perlgpl|perlgpl>.
   2.115 +
   2.116 +The full text of the license can be found in the
   2.117 +LICENSE file included with this module.
   2.118 +
   2.119 +=head1 DISCLAIMER OF WARRANTY
   2.120 +
   2.121 +BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
   2.122 +FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
   2.123 +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
   2.124 +PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
   2.125 +EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
   2.126 +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
   2.127 +ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
   2.128 +YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
   2.129 +NECESSARY SERVICING, REPAIR, OR CORRECTION.
   2.130 +
   2.131 +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
   2.132 +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
   2.133 +REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE
   2.134 +LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL,
   2.135 +OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
   2.136 +THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
   2.137 +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
   2.138 +FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
   2.139 +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
   2.140 +SUCH DAMAGES.
   2.141 +
   2.142 +=cut
   2.143 +
     3.1 --- a/lib/Dist/Zilla/CSJEWELL.pm	Wed Aug 11 23:15:51 2010 -0600
     3.2 +++ b/lib/Dist/Zilla/CSJEWELL.pm	Wed Aug 11 23:16:55 2010 -0600
     3.3 @@ -71,7 +71,7 @@
     3.4  
     3.5  =head1 CONFIGURATION AND ENVIRONMENT
     3.6  
     3.7 -The configuration questions are asked for 
     3.8 +The configuration questions are asked for in the C<dzil configure_CSJEWELL> command.
     3.9  
    3.10  =for readme continue
    3.11