Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

v0.08 released to CPAN #1

Merged
merged 40 commits into from

2 participants

@mjgardner

Since @nothingmuch already made me a comaint last year, I sent a new release to CPAN that doesn't have "./" prepended to all the files in the tarball. That way cpanm won't complain.

Also at @nothingmuch's suggestion I'm thinking about merging this with MouseX::App::Cmd, which shares a lot of code.

Mark Gardner added some commits
Mark Gardner update changelog and Makefile for my repackaging cd46944
Mark Gardner bump version e7344ea
Mark Gardner convert to Dist::Zilla, add all necessary metadata b56257e
Mark Gardner add abstract to main module, fixes RT#75446 b2b71b4
Mark Gardner ignore Dist::Zilla artifacts 750f475
Mark Gardner require Getopt::Long::Descriptive 0.091 for configfile and basic test…
…s (RT#75447)
4386de8
Mark Gardner use current standard MANIFEST.SKIP 4924f53
Mark Gardner build out what I currently use with Dist::Zilla af626f4
Mark Gardner generate README for GitHub eab6580
Mark Gardner get GitHub metadata from my repo dd3732f
Mark Gardner remove pod that Pod::Weaver can generate 8c9a81b
Mark Gardner explicitly use perl version, unload Moose when done fcaa999
Mark Gardner make sure no code before strictures/warnings f93d39e
Mark Gardner perltidy 34d18a0
Mark Gardner unpack @_ earlier in BUILDARGS bf19efa
Mark Gardner make all methods return a297746
Mark Gardner pod fixes 94be959
Mark Gardner use MooseX::Has::Options, remove double quotes d36da31
Mark Gardner no magic punctuation variables 6f4c94f
Mark Gardner couple minor perlcritic fixes 9cd817b
Mark Gardner get rid of vague $arg0 temp var 51eae4f
Mark Gardner get rid of double-sigil derefs 90ddb67
Mark Gardner guard Getopt::Long::Parser against perlcritic 5f52880
Mark Gardner more perlcritic-driven disambiguation e6ece3c
Mark Gardner move TODO to separate file b193b1d
Mark Gardner make changelog CPAN::Changes::Spec compliant 64b24b5
Mark Gardner add pod coverage to BUILD method 8f53432
Mark Gardner remove unused variables d083f44
Mark Gardner make "see also" note in SYNOPSIS a separate section f70b65d
Mark Gardner better unpacking of @_ in BUILDARGS 90ae6ba
Mark Gardner explicitly override with Moose App::Cmd's arg processing 6fb3c44
Mark Gardner shut perlcritic up about overriding MooseX::Getopt's _usage_format cf8238d
Mark Gardner clean up more perlcritic and Moose droppings 3f9791d
Mark Gardner add a mess of develop and test metadata 81271d8
Mark Gardner update changelog for next release 738dc04
Mark Gardner RT#74668: use a sub {} for configfile default (yanick++) 21d2c72
Mark Gardner updated README 821e020
Mark Gardner remove redundant load test 95ac02b
Mark Gardner v0.09
    - RT#74668: can use a sub {} for configfile default (yanick)
    - RT#75446: add all necessary metadata as part of conversion
      to Dist::Zilla (mjgardner)
    - RT#75447: require correct version of Getopt::Long::Descriptive so
      basic and configfile tests can pass (mjgardner)
    - lots of code and documentation cleanup, driven by
      release tests (mjgardner)
1961d18
Mark Gardner v0.09 89e720e
@OfferKaye OfferKaye merged commit 6927dee into OfferKaye:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 15, 2012
  1. update changelog and Makefile for my repackaging

    Mark Gardner authored
  2. bump version

    Mark Gardner authored
Commits on Mar 17, 2012
  1. convert to Dist::Zilla, add all necessary metadata

    Mark Gardner authored
  2. add abstract to main module, fixes RT#75446

    Mark Gardner authored
Commits on Mar 18, 2012
  1. ignore Dist::Zilla artifacts

    Mark Gardner authored
  2. require Getopt::Long::Descriptive 0.091 for configfile and basic test…

    Mark Gardner authored
    …s (RT#75447)
  3. use current standard MANIFEST.SKIP

    Mark Gardner authored
  4. build out what I currently use with Dist::Zilla

    Mark Gardner authored
  5. generate README for GitHub

    Mark Gardner authored
  6. get GitHub metadata from my repo

    Mark Gardner authored
  7. remove pod that Pod::Weaver can generate

    Mark Gardner authored
  8. explicitly use perl version, unload Moose when done

    Mark Gardner authored
  9. make sure no code before strictures/warnings

    Mark Gardner authored
  10. perltidy

    Mark Gardner authored
  11. unpack @_ earlier in BUILDARGS

    Mark Gardner authored
  12. make all methods return

    Mark Gardner authored
  13. pod fixes

    Mark Gardner authored
  14. use MooseX::Has::Options, remove double quotes

    Mark Gardner authored
  15. no magic punctuation variables

    Mark Gardner authored
  16. couple minor perlcritic fixes

    Mark Gardner authored
  17. get rid of vague $arg0 temp var

    Mark Gardner authored
  18. get rid of double-sigil derefs

    Mark Gardner authored
  19. guard Getopt::Long::Parser against perlcritic

    Mark Gardner authored
  20. more perlcritic-driven disambiguation

    Mark Gardner authored
  21. move TODO to separate file

    Mark Gardner authored
  22. make changelog CPAN::Changes::Spec compliant

    Mark Gardner authored
  23. add pod coverage to BUILD method

    Mark Gardner authored
  24. remove unused variables

    Mark Gardner authored
  25. make "see also" note in SYNOPSIS a separate section

    Mark Gardner authored
  26. better unpacking of @_ in BUILDARGS

    Mark Gardner authored
  27. clean up more perlcritic and Moose droppings

    Mark Gardner authored
  28. add a mess of develop and test metadata

    Mark Gardner authored
  29. update changelog for next release

    Mark Gardner authored
Commits on Mar 19, 2012
  1. updated README

    Mark Gardner authored
  2. remove redundant load test

    Mark Gardner authored
  3. v0.09

    Mark Gardner authored
        - RT#74668: can use a sub {} for configfile default (yanick)
        - RT#75446: add all necessary metadata as part of conversion
          to Dist::Zilla (mjgardner)
        - RT#75447: require correct version of Getopt::Long::Descriptive so
          basic and configfile tests can pass (mjgardner)
        - lots of code and documentation cleanup, driven by
          release tests (mjgardner)
  4. v0.09

    Mark Gardner authored
This page is out of date. Refresh to see the latest.
View
2  .gitignore
@@ -0,0 +1,2 @@
+/.build
+/MooseX-App-Cmd-*
View
39 Changes
@@ -1,23 +1,42 @@
-0.07
- - fix tests that started failing due to dependency error string change (offerk)
+Revision history for MooseX-App-Cmd
-0.06
+{{$NEXT}}
+
+0.09 2012-03-18 20:21:21 America/New_York
+ - RT#74668: can use a sub {} for configfile default (yanick)
+ - RT#75446: add all necessary metadata as part of conversion
+ to Dist::Zilla (mjgardner)
+ - RT#75447: require correct version of Getopt::Long::Descriptive so
+ basic and configfile tests can pass (mjgardner)
+ - lots of code and documentation cleanup, driven by
+ release tests (mjgardner)
+
+0.08 2012-03-14
+ - no code changes, just repackaging distribution archive with
+ correct root (mjgardner)
+
+0.07 2012-02-29
+ - fix tests that started failing due to dependency error
+ string change (offerk)
+
+0.06 2009-09-17
- various fixes for upstream version of App::Cmd (vovkasm & brunov)
-0.05
+0.05 2009-07-05
- Various minor fixes due to upstream module changes
-0.04
+0.04 2008-07-17
- Fix failing test when no Test::Output is available.
No code change (lestrrat)
-0.03
- - EMulate App::Cmd's new + tests (groditi)
+0.03 2008-07-15
+ - Emulate App::Cmd's new + tests (groditi)
- Fix for newest MX::Getopt (dann)
- - Add the ability to handle --configfile when used with MX::ConfigFromFile (lestrrat)
+ - Add the ability to handle --configfile when used
+ with MX::ConfigFromFile (lestrrat)
-0.02
+0.02 2008-01-21
- Use MooseX::Getopt 0.09's Getopt::Long::Descriptive features
-0.01
+0.01 2008-01-15
- Initial version
View
38 MANIFEST.SKIP
@@ -1,3 +1,4 @@
+#!start included /home/gardnerm/perl5/perlbrew/perls/perl-5.14.2-usethreads/lib/site_perl/5.14.2/ExtUtils/MANIFEST.SKIP
# Avoid version control files.
\bRCS\b
\bCVS\b
@@ -5,7 +6,14 @@
,v$
\B\.svn\b
\B\.git\b
+\B\.gitignore\b
\b_darcs\b
+\B\.cvsignore$
+
+# Avoid VMS specific MakeMaker generated files
+\bDescrip.MMS$
+\bDESCRIP.MMS$
+\bdescrip.mms$
# Avoid Makemaker generated and utility files.
\bMANIFEST\.bak
@@ -19,6 +27,10 @@
# Avoid Module::Build generated and utility files.
\bBuild$
\b_build/
+\bBuild.bat$
+\bBuild.COM$
+\bBUILD.COM$
+\bbuild.com$
# Avoid temp and backup files.
~$
@@ -26,19 +38,21 @@
\#$
\b\.#
\.bak$
+\.tmp$
+\.#
+\.rej$
-# Avoid Devel::Cover files.
-\bcover_db\b
-
-### DEFAULT MANIFEST.SKIP ENDS HERE ####
+# Avoid OS-specific files/dirs
+# Mac OSX metadata
+\B\.DS_Store
+# Mac OSX SMB mount metadata files
+\B\._
-\.DS_Store$
-\.sw.$
-(\w+-)*(\w+)-\d\.\d+(?:\.tar\.gz)?$
-
-\.t\.log$
+# Avoid Devel::Cover and Devel::CoverX::Covered files.
+\bcover_db\b
+\bcovered\b
-\.prove$
+# Avoid MYMETA files
+^MYMETA\.
+#!end included /home/gardnerm/perl5/perlbrew/perls/perl-5.14.2-usethreads/lib/site_perl/5.14.2/ExtUtils/MANIFEST.SKIP
-# XS shit
-\.(?:bs|c|o)$
View
21 Makefile.PL
@@ -1,21 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-
-use ExtUtils::MakeMaker;
-
-WriteMakefile(
- NAME => 'MooseX::App::Cmd',
- VERSION_FROM => 'lib/MooseX/App/Cmd.pm',
- INSTALLDIRS => 'site',
- SIGN => 1,
- PL_FILES => {},
- PREREQ_PM => {
- 'Test::use::ok' => 0,
- 'App::Cmd' => 0.3,
- 'Moose' => 0.86,
- 'MooseX::Getopt' => "0.18",
- 'Getopt::Long::Descriptive' => 0,
- },
-);
-
View
225 README.pod
@@ -0,0 +1,225 @@
+=pod
+
+=for :stopwords Yuval Kogman Guillermo Roditi Daisuke Maki Vladimir Timofeev Bruno Vecchi
+Offer Kaye Mark Gardner Yanick Champoux Infinity Interactive, cpan
+testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto
+metadata placeholders metacpan
+
+=head1 NAME
+
+MooseX::App::Cmd - Mashes up MooseX::Getopt and App::Cmd
+
+=head1 VERSION
+
+version 0.09
+
+=head1 SYNOPSIS
+
+ package YourApp::Cmd;
+ use Moose;
+
+ extends qw(MooseX::App::Cmd);
+
+
+ package YourApp::Cmd::Command::blort;
+ use Moose;
+
+ extends qw(MooseX::App::Cmd::Command);
+
+ has blortex => (
+ traits => [qw(Getopt)],
+ isa => 'Bool',
+ is => 'rw',
+ cmd_aliases => 'X',
+ documentation => 'use the blortext algorithm',
+ );
+
+ has recheck => (
+ traits => [qw(Getopt)],
+ isa => 'Bool',
+ is => 'rw',
+ cmd_aliases => 'r',
+ documentation => 'recheck all results',
+ );
+
+ sub execute {
+ my ( $self, $opt, $args ) = @_;
+
+ # you may ignore $opt, it's in the attributes anyway
+
+ my $result = $self->blortex ? blortex() : blort();
+
+ recheck($result) if $self->recheck;
+
+ print $result;
+ }
+
+=head1 DESCRIPTION
+
+This module marries L<App::Cmd|App::Cmd> with L<MooseX::Getopt|MooseX::Getopt>.
+
+Use it like L<App::Cmd|App::Cmd> advises (especially see
+L<App::Cmd::Tutorial|App::Cmd::Tutorial>), swapping
+L<App::Cmd::Command|App::Cmd::Command> for
+L<MooseX::App::Cmd::Command|MooseX::App::Cmd::Command>.
+
+Then you can write your moose commands as Moose classes, with
+L<MooseX::Getopt|MooseX::Getopt>
+defining the options for you instead of C<opt_spec> returning a
+L<Getopt::Long::Descriptive|Getopt::Long::Descriptive> spec.
+
+=head1 METHODS
+
+=head2 BUILD
+
+After calling C<new> this method is automatically run, setting underlying
+L<App::Cmd|App::Cmd> attributes as per its documentation.
+
+=head1 SEE ALSO
+
+=over
+
+=item L<App::Cmd|App::Cmd>
+
+=item L<App::Cmd::Tutorial|App::Cmd::Tutorial>
+
+=item L<MooseX::Getopt|MooseX::Getopt>
+
+=item L<MooseX::App::Cmd::Command|MooseX::App::Cmd::Command>
+
+=back
+
+=head1 SUPPORT
+
+=head2 Perldoc
+
+You can find documentation for this module with the perldoc command.
+
+ perldoc MooseX::App::Cmd
+
+=head2 Websites
+
+The following websites have more information about this module, and may be of help to you. As always,
+in addition to those websites please use your favorite search engine to discover more resources.
+
+=over 4
+
+=item *
+
+Search CPAN
+
+The default CPAN search engine, useful to view POD in HTML format.
+
+L<http://search.cpan.org/dist/MooseX-App-Cmd>
+
+=item *
+
+AnnoCPAN
+
+The AnnoCPAN is a website that allows community annotations of Perl module documentation.
+
+L<http://annocpan.org/dist/MooseX-App-Cmd>
+
+=item *
+
+CPAN Ratings
+
+The CPAN Ratings is a website that allows community ratings and reviews of Perl modules.
+
+L<http://cpanratings.perl.org/d/MooseX-App-Cmd>
+
+=item *
+
+CPANTS
+
+The CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution.
+
+L<http://cpants.perl.org/dist/overview/MooseX-App-Cmd>
+
+=item *
+
+CPAN Testers
+
+The CPAN Testers is a network of smokers who run automated tests on uploaded CPAN distributions.
+
+L<http://www.cpantesters.org/distro/M/MooseX-App-Cmd>
+
+=item *
+
+CPAN Testers Matrix
+
+The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms.
+
+L<http://matrix.cpantesters.org/?dist=MooseX-App-Cmd>
+
+=item *
+
+CPAN Testers Dependencies
+
+The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution.
+
+L<http://deps.cpantesters.org/?module=MooseX::App::Cmd>
+
+=back
+
+=head2 Bugs / Feature Requests
+
+Please report any bugs or feature requests through the web
+interface at L<https://github.com/mjgardner/moosex-app-cmd/issues>. You will be automatically notified of any
+progress on the request by the system.
+
+=head2 Source Code
+
+The code is open to the world, and available for you to hack on. Please feel free to browse it and play
+with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull
+from your repository :)
+
+L<https://github.com/mjgardner/moosex-app-cmd>
+
+ git clone git://github.com/mjgardner/moosex-app-cmd.git
+
+=head1 AUTHORS
+
+=over 4
+
+=item *
+
+Yuval Kogman <nothingmuch@woobling.org>
+
+=item *
+
+Guillermo Roditi <groditi@cpan.org>
+
+=item *
+
+Daisuke Maki <dmaki@cpan.org>
+
+=item *
+
+Vladimir Timofeev <vovkasm@gmail.com>
+
+=item *
+
+Bruno Vecchi <brunov@cpan.org>
+
+=item *
+
+Offer Kaye <offerk@cpan.org>
+
+=item *
+
+Mark Gardner <mjgardner@cpan.org>
+
+=item *
+
+Yanick Champoux <yanick+cpan@babyl.dyndns.org>
+
+=back
+
+=head1 COPYRIGHT AND LICENSE
+
+This software is copyright (c) 2012 by Infinity Interactive, Yuval Kogman.
+
+This is free software; you can redistribute it and/or modify it under
+the same terms as the Perl 5 programming language system itself.
+
View
6 TODO
@@ -0,0 +1,6 @@
+Full support for Getopt::Long::Descriptive's abilities is not yet written.
+
+This entails taking apart the attributes and getting at the descriptions.
+
+This might actually be added upstream to MooseX::Getopt, so until we decide
+here's a functional but not very helpful (to the user) version anyway.
View
66 dist.ini
@@ -0,0 +1,66 @@
+name = MooseX-App-Cmd
+author = Yuval Kogman <nothingmuch@woobling.org>
+author = Guillermo Roditi <groditi@cpan.org>
+author = Daisuke Maki <dmaki@cpan.org>
+author = Vladimir Timofeev <vovkasm@gmail.com>
+author = Bruno Vecchi <brunov@cpan.org>
+author = Offer Kaye <offerk@cpan.org>
+author = Mark Gardner <mjgardner@cpan.org>
+author = Yanick Champoux <yanick+cpan@babyl.dyndns.org>
+license = Perl_5
+copyright_holder = Infinity Interactive, Yuval Kogman
+
+[@Filter]
+-bundle = @Basic
+-remove = Readme
+[AutoPrereqs]
+[Prereqs]
+perl = 5.006
+App::Cmd = 0.3
+Getopt::Long::Descriptive = 0.091
+Moose = 0.86
+MooseX::Getopt = 0.18
+Test::use::ok = 0
+[Prereqs / ConfigureRequires]
+ExtUtils::MakeMaker = 0
+[Prereqs / BuildRequires]
+ExtUtils::MakeMaker = 0
+[Prereqs / DevelopRequires]
+Dist::Zilla = 0
+Pod::Weaver::Plugin::Encoding = 0
+Pod::Weaver::Plugin::StopWords = 0
+Pod::Weaver::Section::Support = 0
+Perl::Critic::Pulp = 0
+Perl::Critic::Lax = 0
+Perl::Critic::StricterSubs = 0
+Perl::Critic::Bangs = 0
+[Prereqs / DevelopRecommends]
+Test::EOL = 0
+[Prereqs / TestRecommends]
+Test::CPAN::Meta::JSON = 0
+[NextRelease]
+[OurPkgVersion]
+[PodWeaver]
+[MetaConfig]
+[@TestingMania]
+[PerlTidy]
+perltidyrc = xt/author/perltidy.rc
+[ReadmeAnyFromPod]
+[ReadmeAnyFromPod / ReadmePodInRoot]
+type = pod
+filename = README.pod
+location = root
+[ReportVersions]
+[InstallGuide]
+[MetaJSON]
+[@Git]
+allow_dirty = README.pod
+[Git::CommitBuild]
+branch =
+release_branch = release_build/%b
+[Git::NextVersion]
+[@GitHub]
+metacpan = 1
+[GitHub::Meta]
+fork = 0
+[InstallRelease]
View
100 lib/MooseX/App/Cmd.pm
@@ -1,51 +1,45 @@
-#!/usr/bin/perl
+use 5.006;
package MooseX::App::Cmd;
-use File::Basename ();
use Moose;
+use English '-no_match_vars';
+use File::Basename ();
+# VERSION
+use MooseX::MarkAsMethods autoclean => 1;
extends qw(Moose::Object App::Cmd);
sub BUILDARGS {
- my $class = shift;
- return {} unless @_;
- return { arg => $_[0] } if @_ == 1;;
- return { @_ };
+ my ( undef, @arg ) = @_;
+ return {} if !@arg;
+ return { arg => $arg[0] } if @arg == 1;
+ return {@arg};
}
sub BUILD {
- my ($self,$args) = @_;
-
- my $class = blessed $self;
- my $arg0 = $0;
- $self->{arg0} = File::Basename::basename($arg0);
- $self->{command} = $class->_command( {} );
- $self->{full_arg0} = $arg0;
+ my $self = shift;
+ my $class = blessed $self;
+ $self->{arg0} = File::Basename::basename($PROGRAM_NAME);
+ $self->{command} = $class->_command( {} );
+ $self->{full_arg0} = $PROGRAM_NAME;
+ return;
}
-our $VERSION = "0.07";
-
-__PACKAGE__;
-
-__END__
-
-=pod
+## no critic (Modules::RequireExplicitInclusion)
+__PACKAGE__->meta->make_immutable();
+no Moose;
+1;
-=head1 NAME
-
-MooseX::App::Cmd - Mashes up L<MooseX::Getopt> and L<App::Cmd>.
+# ABSTRACT: Mashes up MooseX::Getopt and App::Cmd
=head1 SYNOPSIS
-See L<App::Cmd/SYNOPSIS>.
-
package YourApp::Cmd;
use Moose;
extends qw(MooseX::App::Cmd);
-
package YourApp::Cmd::Command::blort;
use Moose;
@@ -53,59 +47,61 @@ See L<App::Cmd/SYNOPSIS>.
has blortex => (
traits => [qw(Getopt)],
- isa => "Bool",
- is => "rw",
- cmd_aliases => "X",
- documentation => "use the blortext algorithm",
+ isa => 'Bool',
+ is => 'rw',
+ cmd_aliases => 'X',
+ documentation => 'use the blortext algorithm',
);
has recheck => (
traits => [qw(Getopt)],
- isa => "Bool",
- is => "rw",
- cmd_aliases => "r",
- documentation => "recheck all results",
+ isa => 'Bool',
+ is => 'rw',
+ cmd_aliases => 'r',
+ documentation => 'recheck all results',
);
sub execute {
my ( $self, $opt, $args ) = @_;
# you may ignore $opt, it's in the attributes anyway
-
+
my $result = $self->blortex ? blortex() : blort();
recheck($result) if $self->recheck;
print $result;
- }
+ }
=head1 DESCRIPTION
-This module marries L<App::Cmd> with L<MooseX::Getopt>.
+This module marries L<App::Cmd|App::Cmd> with L<MooseX::Getopt|MooseX::Getopt>.
-Use it like L<App::Cmd> advises (especially see L<App::Cmd::Tutorial>),
-swapping L<App::Cmd::Command> for L<MooseX::App::Cmd::Command>.
+Use it like L<App::Cmd|App::Cmd> advises (especially see
+L<App::Cmd::Tutorial|App::Cmd::Tutorial>), swapping
+L<App::Cmd::Command|App::Cmd::Command> for
+L<MooseX::App::Cmd::Command|MooseX::App::Cmd::Command>.
-Then you can write your moose commands as moose classes, with L<MooseX::Getopt>
+Then you can write your moose commands as Moose classes, with
+L<MooseX::Getopt|MooseX::Getopt>
defining the options for you instead of C<opt_spec> returning a
-L<Getopt::Long::Descriptive> spec.
+L<Getopt::Long::Descriptive|Getopt::Long::Descriptive> spec.
-=head1 AUTHOR
+=method BUILD
-Yuval Kogman E<lt>nothingmuch@woobling.orgE<gt>
+After calling C<new> this method is automatically run, setting underlying
+L<App::Cmd|App::Cmd> attributes as per its documentation.
-With contributions from:
+=head1 SEE ALSO
-=over 4
+=over
-=item Guillermo Roditi E<lt>groditi@cpan.orgE<gt>
+=item L<App::Cmd|App::Cmd>
-=back
+=item L<App::Cmd::Tutorial|App::Cmd::Tutorial>
-=head1 COPYRIGHT
+=item L<MooseX::Getopt|MooseX::Getopt>
- Copyright (c) 2007-2008 Infinity Interactive, Yuval Kogman. All rights
- reserved This program is free software; you can redistribute it and/or
- modify it under the same terms as Perl itself.
+=item L<MooseX::App::Cmd::Command|MooseX::App::Cmd::Command>
-=cut
+=back
View
117 lib/MooseX/App/Cmd/Command.pm
@@ -1,81 +1,84 @@
-#!/usr/bin/perl
+use 5.006;
package MooseX::App::Cmd::Command;
use Moose;
-with qw/MooseX::Getopt/;
-
-extends qw(Moose::Object App::Cmd::Command);
-
-with qw(MooseX::Getopt);
-
+# VERSION
use Getopt::Long::Descriptive ();
+use MooseX::Has::Options;
+use MooseX::MarkAsMethods autoclean => 1;
+extends qw(Moose::Object App::Cmd::Command);
+with 'MooseX::Getopt';
has usage => (
- metaclass => "NoGetopt",
- isa => "Object",
- is => "ro",
- required => 1,
+ qw(:ro :required),
+ metaclass => 'NoGetopt',
+ isa => 'Object',
);
has app => (
- metaclass => "NoGetopt",
- isa => "MooseX::App::Cmd",
- is => "ro",
- required => 1,
+ qw(:ro :required),
+ metaclass => 'NoGetopt',
+ isa => 'MooseX::App::Cmd',
);
-sub _process_args {
- my ( $class, $args, @params ) = @_;
- local @ARGV = @$args;
+override _process_args => sub {
+ my ( $class, $args ) = @_;
+ local @ARGV = @{$args};
my $config_from_file;
- if($class->meta->does_role('MooseX::ConfigFromFile')) {
+ if ( $class->meta->does_role('MooseX::ConfigFromFile') ) {
local @ARGV = @ARGV;
my $configfile;
- my $opt_parser = Getopt::Long::Parser->new( config => [ qw( pass_through
- ) ] );
- $opt_parser->getoptions( "configfile=s" => \$configfile ); if(!defined $configfile) {
+ my $opt_parser;
+ {
+ ## no critic (Modules::RequireExplicitInclusion)
+ $opt_parser
+ = Getopt::Long::Parser->new( config => ['pass_through'] );
+ }
+ $opt_parser->getoptions( 'configfile=s' => \$configfile );
+ if ( !defined $configfile ) {
my $cfmeta = $class->meta->find_attribute_by_name('configfile');
- $configfile = $cfmeta->default if $cfmeta->has_default;
+ if ( $cfmeta->has_default ) {
+ my $default = $cfmeta->default;
+ $configfile
+ = ref $default eq 'CODE' ? $default->() : $default;
+ }
}
- if(defined $configfile) {
+ if ( defined $configfile ) {
$config_from_file = $class->get_config_from_file($configfile);
}
}
my %processed = $class->_parse_argv(
params => { argv => \@ARGV },
- options => [ $class->_attrs_to_options( $config_from_file ) ],
+ options => [ $class->_attrs_to_options($config_from_file) ],
);
return (
$processed{params},
$processed{argv},
usage => $processed{usage},
+
# params from CLI are also fields in MooseX::Getopt
- %{ $config_from_file ?
- { %$config_from_file, %{$processed{params}} } :
- $processed{params} },
+ $config_from_file
+ ? ( %{$config_from_file}, %{ $processed{params} } )
+ : %{ $processed{params} },
);
-}
+};
-sub _usage_format {
- my $class = shift;
- $class->usage_desc();
+sub _usage_format { ## no critic (ProhibitUnusedPrivateSubroutines)
+ return shift->usage_desc;
}
-__PACKAGE__;
-
-__END__
-
-=pod
-
-=head1 NAME
+## no critic (Modules::RequireExplicitInclusion)
+__PACKAGE__->meta->make_immutable();
+no Moose;
+1;
-MooseX::App::Cmd::Command - Base class for L<MooseX::Getopt> based L<App::Cmd::Command>s.
+# ABSTRACT: Base class for MooseX::Getopt based App::Cmd::Commands
=head1 SYNOPSIS
@@ -86,8 +89,8 @@ MooseX::App::Cmd::Command - Base class for L<MooseX::Getopt> based L<App::Cmd::C
# no need to set opt_spec
# see MooseX::Getopt for documentation on how to specify options
has option_field => (
- isa => "Str",
- is => "rw",
+ isa => 'Str',
+ is => 'rw',
required => 1,
);
@@ -99,29 +102,11 @@ MooseX::App::Cmd::Command - Base class for L<MooseX::Getopt> based L<App::Cmd::C
=head1 DESCRIPTION
-This is a replacement base class for L<App::Cmd::Command> classes that includes
-L<MooseX::Getopt> and the glue to combine the two.
-
-=head1 METHODS
-
-=over 4
-
-=item _process_args
-
-Replaces L<App::Cmd::Command>'s argument processing in in favour of
-L<MooseX::Getopt> based processing.
-
-=back
-
-=head1 TODO
-
-Full support for L<Getopt::Long::Descriptive>'s abilities is not yet written.
-
-This entails taking apart the attributes and getting at the descriptions.
-
-This might actually be added upstream to L<MooseX::Getopt>, so until we decide
-here's a functional but not very helpful (to the user) version anyway.
-
-=cut
+This is a replacement base class for L<App::Cmd::Command|App::Cmd::Command>
+classes that includes
+L<MooseX::Getopt|MooseX::Getopt> and the glue to combine the two.
+=method _process_args
+Replaces L<App::Cmd::Command|App::Cmd::Command>'s argument processing in favor
+of L<MooseX::Getopt|MooseX::Getopt> based processing.
View
19 perlcritic.rc
@@ -0,0 +1,19 @@
+severity = brutal
+verbose = 8
+exclude = CodeLayout::RequireUseUTF8 Compatibility::PodMinimumVersion Documentation::RequirePODUseEncodingUTF8 Editor::RequireEmacsFileVariables Miscellanea::RequireRcsKeywords Modules::RequireExplicitPackage CodeLayout::ProhibitHashBarewords Tics::ProhibitLongLines
+
+[Lax::RequireExplicitPackage::ExceptForPragmata]
+allowed_pragmata = diagnostics feature perlversion strict warnings utf8
+
+[Documentation::PodSpelling]
+stop_words = bugtracker Perldoc perldoc
+
+[Documentation::RequirePodSections]
+lib_sections = NAME | VERSION | DESCRIPTION | SYNOPSIS | COPYRIGHT AND LICENSE
+script_sections = NAME | USAGE | OPTIONS | EXIT STATUS | COPYRIGHT AND LICENSE
+
+[Subroutines::ProhibitCallsToUndeclaredSubs]
+exempt_subs = Moose::blessed Moose::extends Moose::has Moose::override Moose::with
+
+[Subroutines::ProhibitUnusedPrivateSubroutines]
+private_name_regex = _(?!build_)\w+
View
7 t/00-load.t
@@ -1,7 +0,0 @@
-#!perl -T
-
-use Test::More tests => 2;
-
-use ok 'MooseX::App::Cmd';
-use ok 'MooseX::App::Cmd::Command';
-
View
102 t/basic.t
@@ -11,81 +11,79 @@ use Test::MyCmd;
my $cmd = Test::MyCmd->new;
-isa_ok($cmd, 'Test::MyCmd');
+isa_ok( $cmd, 'Test::MyCmd' );
is_deeply(
- [ sort $cmd->command_names ],
- [ sort qw(help --help -h -? commands frob frobulate justusage stock bark) ],
- "got correct list of registered command names",
+ [ sort $cmd->command_names ],
+ [ sort
+ qw(help --help -h -? commands frob frobulate justusage stock bark)
+ ],
+ 'got correct list of registered command names',
);
use Data::Dumper;
Dumper $cmd->command_plugins;
is_deeply(
- [ sort $cmd->command_plugins ],
- [ qw(
- App::Cmd::Command::commands
- App::Cmd::Command::help
- Test::MyCmd::Command::bark
- Test::MyCmd::Command::frobulate
- Test::MyCmd::Command::justusage
- Test::MyCmd::Command::stock
- ) ],
- "got correct list of registered command plugins",
+ [ sort $cmd->command_plugins ],
+ [ qw(
+ App::Cmd::Command::commands
+ App::Cmd::Command::help
+ Test::MyCmd::Command::bark
+ Test::MyCmd::Command::frobulate
+ Test::MyCmd::Command::justusage
+ Test::MyCmd::Command::stock
+ )
+ ],
+ 'got correct list of registered command plugins',
);
{
- local @ARGV = qw(frob --widget wname your fat face);
- eval { $cmd->run };
-
- is(
- $@,
- "the widget name is wname - your fat face\n",
- "command died with the correct string",
- );
+ local @ARGV = qw(frob --widget wname your fat face);
+ eval { $cmd->run };
+
+ is( $@,
+ "the widget name is wname - your fat face\n",
+ 'command died with the correct string',
+ );
}
{
- local @ARGV = qw(justusage);
- eval { $cmd->run };
-
- my $error = $@;
-
- like(
- $error,
- qr/^basic.t justusage/,
- "default usage_desc is okay",
- );
+ local @ARGV = qw(justusage);
+ eval { $cmd->run };
+
+ my $error = $@;
+
+ like( $error, qr/^basic.t justusage/, 'default usage_desc is okay' );
}
{
- local @ARGV = qw(stock);
- eval { $cmd->run };
-
- like($@, qr/mandatory method/, "un-subclassed &run leads to death");
+ local @ARGV = qw(stock);
+ eval { $cmd->run };
+
+ like( $@, qr/mandatory method/, 'un-subclassed &run leads to death' );
}
{
- local @ARGV = qw(bark);
- eval { $cmd->run };
-
- like(
- $@,
- qr/Mandatory parameter 'wow' missing in call to \(eval\)/,
- "required option field is missing",
- );
+ local @ARGV = qw(bark);
+ eval { $cmd->run };
+
+ like(
+ $@,
+ qr/Mandatory parameter 'wow' missing in call to \(eval\)/,
+ 'required option field is missing',
+ );
}
SKIP: {
- my $have_TO = eval { require Test::Output; 1; };
- print STDERR $@;
- skip "these tests require Test::Output", 5 unless $have_TO;
+ my $have_TO = eval { require Test::Output; 1; };
+ print STDERR $@;
+ skip 'these tests require Test::Output', 5 unless $have_TO;
- local @ARGV = qw(commands);
+ local @ARGV = qw(commands);
- my ($output) = Test::Output::output_from(sub { $cmd->run });
+ my ($output) = Test::Output::output_from( sub { $cmd->run } );
- for my $name (qw(commands frobulate justusage stock bark)) {
- like($output, qr/^\s+\Q$name\E/sm, "$name plugin in listing");
- }
+ for my $name (qw(commands frobulate justusage stock bark)) {
+ like( $output, qr/^\s+\Q$name\E/sm, "$name plugin in listing" );
+ }
}
View
12 t/build_emulates_new.t
@@ -6,13 +6,13 @@ use warnings;
use Test::More tests => 1;
{
- package Foo;
- use base 'App::Cmd';
+ package Foo;
+ use base 'App::Cmd';
- package Bar;
- use Moose;
- extends 'MooseX::App::Cmd';
+ package Bar;
+ use Moose;
+ extends 'MooseX::App::Cmd';
}
-is_deeply(\%{ Bar->new }, \%{ Foo->new }, 'Internal hashes match');
+is_deeply( \%{ Bar->new }, \%{ Foo->new }, 'Internal hashes match' );
View
54 t/configfile.t
@@ -4,16 +4,17 @@ use strict;
use warnings;
use Test::More;
-BEGIN
-{
+BEGIN {
eval {
require MooseX::ConfigFromFile;
require YAML;
};
if ($@) {
- plan( skip_all => "These tests require MooseX::ConfigFromFile and YAML" );
- } else {
- plan( tests => 2 );
+ plan skip_all =>
+ 'These tests require MooseX::ConfigFromFile and YAML';
+ }
+ else {
+ plan tests => 3;
}
}
@@ -23,23 +24,34 @@ use Test::ConfigFromFile;
my $cmd = Test::ConfigFromFile->new;
{
- local @ARGV = qw(moo);
- eval { $cmd->run };
-
- like(
- $@,
- qr/Mandatory parameter 'moo' missing in call to \(eval\)/,
- "command died with the correct string",
- );
+ local @ARGV = qw(moo);
+ eval { $cmd->run };
+
+ like(
+ $@,
+ qr/Mandatory parameter 'moo' missing in call to \(eval\)/,
+ 'command died with the correct string',
+ );
+}
+
+{
+ local @ARGV = qw(moo --configfile=t/lib/Test/ConfigFromFile/config.yaml);
+ eval { $cmd->run };
+
+ like(
+ $@,
+ qr/cows go moo1 moo2 moo3/,
+ 'command died with the correct string',
+ );
}
{
- local @ARGV = qw(moo --configfile=t/lib/Test/ConfigFromFile/config.yaml);
- eval { $cmd->run };
-
- like(
- $@,
- qr/cows go moo1 moo2 moo3/,
- "command died with the correct string",
- );
+ local @ARGV = qw(boo);
+ eval { $cmd->run };
+
+ like(
+ $@,
+ qr/ghosts go moo1 moo2 moo3/,
+ 'default configfile() takes a sub()',
+ );
}
View
37 t/lib/Test/ConfigFromFile/Command/boo.pm
@@ -0,0 +1,37 @@
+package Test::ConfigFromFile::Command::boo;
+use Moose;
+use YAML();
+
+extends qw(MooseX::App::Cmd::Command);
+with 'MooseX::ConfigFromFile';
+
+=head1 NAME
+
+Test::MyCmd::Command::boo - reads from config file
+
+=cut
+
+has 'moo' => (
+ isa => "ArrayRef",
+ is => "ro",
+ required => 1,
+ auto_deref => 1,
+ documentation => "required option field",
+);
+
+has '+configfile' =>
+ ( default => sub {'t/lib/Test/ConfigFromFile/config.yaml'}, );
+
+sub execute {
+ my ( $self, $opt, $arg ) = @_;
+
+ die( "ghosts go " . join( ' ', $self->moo ) );
+}
+
+sub get_config_from_file {
+ my ( $self, $file ) = @_;
+
+ return YAML::LoadFile($file);
+}
+
+1;
View
14 t/lib/Test/ConfigFromFile/Command/moo.pm
@@ -12,21 +12,21 @@ Test::MyCmd::Command::moo - reads from config file
=cut
has 'moo' => (
- isa => "ArrayRef",
- is => "ro",
- required => 1,
- auto_deref => 1,
+ isa => "ArrayRef",
+ is => "ro",
+ required => 1,
+ auto_deref => 1,
documentation => "required option field",
);
sub execute {
- my ($self, $opt, $arg) =@_;
+ my ( $self, $opt, $arg ) = @_;
- die ("cows go " . join(' ', $self->moo));
+ die( "cows go " . join( ' ', $self->moo ) );
}
sub get_config_from_file {
- my ($self, $file) = @_;
+ my ( $self, $file ) = @_;
return YAML::LoadFile($file);
}
View
10 t/lib/Test/MyCmd/Command/bark.pm
@@ -10,16 +10,16 @@ Test::MyCmd::Command::bark - required field is used
=cut
has wow => (
- isa => "Str",
- is => "ro",
- required => 1,
+ isa => "Str",
+ is => "ro",
+ required => 1,
documentation => "required option field",
);
sub execute {
- my ($self, $opt, $arg) =@_;
+ my ( $self, $opt, $arg ) = @_;
- die "my dog name barks " . $self->wow . "\n";
+ die "my dog name barks " . $self->wow . "\n";
}
1;
View
20 t/lib/Test/MyCmd/Command/frobulate.pm
@@ -4,28 +4,28 @@ use Moose;
extends qw(MooseX::App::Cmd::Command);
sub command_names {
- return qw(frobulate frob);
+ return qw(frobulate frob);
}
has foo_bar => (
- traits => [qw(Getopt)],
- isa => "Bool",
- is => "ro",
- cmd_aliases => "F",
+ traits => [qw(Getopt)],
+ isa => "Bool",
+ is => "ro",
+ cmd_aliases => "F",
documentation => "enable foo-bar subsystem",
);
has widget => (
- traits => [qw(Getopt)],
- isa => "Str",
- is => "ro",
+ traits => [qw(Getopt)],
+ isa => "Str",
+ is => "ro",
documentation => "set widget name",
);
sub execute {
- my ($self, $opt, $arg) = @_;
+ my ( $self, $opt, $arg ) = @_;
- die "the widget name is " . $self->widget . " - @$arg\n";
+ die "the widget name is " . $self->widget . " - @$arg\n";
}
1;
View
4 t/lib/Test/MyCmd/Command/justusage.pm
@@ -10,9 +10,9 @@ Test::MyCmd::Command::justusage - it just dies its own usage, no matter what
=cut
sub execute {
- my ($self, $opt, $arg) = @_;
+ my ( $self, $opt, $arg ) = @_;
- die $self->usage->text;
+ die $self->usage->text;
}
1;
View
49 weaver.ini
@@ -0,0 +1,49 @@
+[@CorePrep]
+[-StopWords]
+
+[Region / :stopwords]
+
+[Name]
+[Version]
+
+[Region / prelude]
+
+[Generic / SYNOPSIS]
+[Generic / USAGE]
+[Generic / DESCRIPTION]
+[Generic / OVERVIEW]
+[Generic / REQUIRED ARGUMENTS]
+[Generic / OPTIONS]
+
+[Collect / ATTRIBUTES]
+command = attr
+
+[Collect / METHODS]
+command = method
+
+[Collect / FUNCTIONS]
+command = func
+
+[Collect / TYPES]
+command = type
+
+[Generic / DIAGNOSTICS]
+[Generic / EXIT STATUS]
+[Generic / CONFIGURATION]
+[Generic / CONFIGURATION AND ENVIRONMENT]
+[Generic / DEPENDENCIES]
+[Generic / INCOMPATIBILITIES]
+
+[Leftovers]
+
+[Region / postlude]
+
+[Support]
+all_modules = 1
+bugs = metadata
+bugs_content = Please report any bugs or feature requests through the web
+bugs_content = interface at {WEB}. You will be automatically notified of any
+bugs_content = progress on the request by the system.
+websites = search, anno, ratings, kwalitee, testers, testmatrix, deps
+[Authors]
+[Legal]
View
13 xt/author/perltidy.rc
@@ -0,0 +1,13 @@
+-l=78 # Max line width is 78 cols
+-i=4 # Indent level is 4 cols
+-ci=4 # Continuation indent is 4 cols
+-vt=2 # Maximal vertical tightness
+-cti=0 # No extra indentation for closing brackets
+-pt=1 # Medium parenthesis tightness
+-bt=1 # Medium brace tightness
+-sbt=1 # Medium square bracket tightness
+-bbt=1 # Medium block brace tightness
+-nsfs # No space before semicolons
+-nolq # Don't outdent long quoted strings
+-wbb="% + - * / x != == >= <= =~ !~ < > | & >= < = **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x=" # Break before all operators
+
Something went wrong with that request. Please try again.