PageRenderTime 53ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/Dist/Zilla/App/Command/configure_CSJEWELL.pm

https://bitbucket.org/csjewell/dist-zilla-belike-csjewell
Perl | 140 lines | 54 code | 22 blank | 64 comment | 3 complexity | bcade4a7981ba1d50e7f09882d343ebe MD5 | raw file
  1. package Dist::Zilla::App::Command::configure_CSJEWELL;
  2. use 5.008003;
  3. use strict;
  4. use warnings;
  5. use Dist::Zilla::App -command;
  6. use autodie;
  7. use File::Spec;
  8. our $VERSION = '0.900';
  9. $VERSION =~ s/_//sm;
  10. sub abstract { ## no critic(ProhibitAmbiguousNames)
  11. return q{configure the 'CSJEWELL' minting profile.};
  12. }
  13. sub validate_args {
  14. my ( $self, undef, $args ) = @_;
  15. if ( 0 != @{$args} ) {
  16. $self->usage_error('Too many arguments');
  17. }
  18. return;
  19. }
  20. sub execute {
  21. my ( $self, undef, undef ) = @_;
  22. my $chrome = $self->app()->chrome();
  23. ## no critic(ProtectPrivateSubs)
  24. my $config_root = Dist::Zilla::Util->_global_config_root();
  25. if ( not -d $config_root
  26. or not -f File::Spec->catfile( $config_root, 'config.ini' ) )
  27. {
  28. $chrome->logger()->log_fatal( [
  29. 'A per-user configuration file does not exist in %s',
  30. "$config_root",
  31. ] );
  32. return;
  33. }
  34. my $homepage = $chrome->prompt_str(
  35. 'Where is your homepage?',
  36. { check => sub { defined $_[0] and $_[0] =~ /\S/ms },
  37. default => 'http://search.cpan.org/~username/',
  38. },
  39. );
  40. my $repo = $chrome->prompt_str(
  41. 'Where are your repositories?',
  42. { check => sub { defined $_[0] and $_[0] =~ /\S/ms },
  43. default => 'http://bitbucket.org/username/',
  44. },
  45. );
  46. open my $fh, '>>', $config_root->file('config.ini');
  47. $fh->print("\n[%DefaultURLs]\n");
  48. $fh->print("homepage = $homepage\n");
  49. $fh->print("repository_location = $repo\n\n");
  50. close $fh;
  51. $self->log('Added to config.ini file.');
  52. return;
  53. } ## end sub execute
  54. 1;
  55. __END__
  56. =pod
  57. =head1 NAME
  58. Dist::Zilla::App::Command::configure_CSJEWELL - set up the global config file
  59. =head1 VERSION
  60. This document describes Dist::Zilla::App::Command::configure_CSJEWELL version 0.900.
  61. =head1 SYNOPSIS
  62. C:\> dzil configure_CSJEWELL
  63. This command prompts the user for information that is used in the CSJEWELL
  64. minting profile and stores it in F<config.ini>.
  65. =for Pod::Coverage abstract validate_args execute
  66. =head1 AUTHOR
  67. Curtis Jewell <CSJewell@cpan.org>
  68. =head1 SEE ALSO
  69. L<Dist::Zilla::BeLike::CSJEWELL|Dist::Zilla::BeLike::CSJEWELL>
  70. =head1 LICENSE AND COPYRIGHT
  71. Copyright (c) 2010, Curtis Jewell C<< CSJewell@cpan.org >>.
  72. This module is free software; you can redistribute it and/or
  73. modify it under the same terms as Perl itself, either version
  74. 5.8.1 or any later version. See L<perlartistic|perlartistic>
  75. and L<perlgpl|perlgpl>.
  76. The full text of the license can be found in the
  77. LICENSE file included with this module.
  78. =head1 DISCLAIMER OF WARRANTY
  79. BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
  80. FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
  81. OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
  82. PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
  83. EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  84. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
  85. ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
  86. YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
  87. NECESSARY SERVICING, REPAIR, OR CORRECTION.
  88. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
  89. WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
  90. REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE
  91. LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL,
  92. OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
  93. THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
  94. RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
  95. FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
  96. SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
  97. SUCH DAMAGES.
  98. =cut