[Jifty-commit] r5494 - in jifty/trunk: lib/Jifty lib/Jifty/Script

Jifty commits jifty-commit at lists.jifty.org
Thu Jun 5 19:42:31 EDT 2008


Author: ruz
Date: Thu Jun  5 19:42:31 2008
New Revision: 5494

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/Script.pm
   jifty/trunk/lib/Jifty/Script/Action.pm
   jifty/trunk/lib/Jifty/Script/Adopt.pm
   jifty/trunk/lib/Jifty/Script/App.pm
   jifty/trunk/lib/Jifty/Script/Console.pm
   jifty/trunk/lib/Jifty/Script/Deps.pm
   jifty/trunk/lib/Jifty/Script/Env.pm
   jifty/trunk/lib/Jifty/Script/FastCGI.pm
   jifty/trunk/lib/Jifty/Script/Help.pm
   jifty/trunk/lib/Jifty/Script/ModPerl2.pm
   jifty/trunk/lib/Jifty/Script/Model.pm
   jifty/trunk/lib/Jifty/Script/Plugin.pm
   jifty/trunk/lib/Jifty/Script/Po.pm
   jifty/trunk/lib/Jifty/Script/Repl.pm
   jifty/trunk/lib/Jifty/Script/Schema.pm
   jifty/trunk/lib/Jifty/Script/Script.pm
   jifty/trunk/lib/Jifty/Script/Server.pm

Log:
 r5485 at ruslan-zakirovs-computer:  ruz | 2008-05-23 19:31:49 +0400
 * local copy
 r5486 at ruslan-zakirovs-computer:  ruz | 2008-05-24 00:17:52 +0400
 * move print_help method into base class
 r5487 at ruslan-zakirovs-computer:  ruz | 2008-05-24 00:29:40 +0400
 * use Jifty::Script as base class
 r5488 at ruslan-zakirovs-computer:  ruz | 2008-05-24 01:02:05 +0400
 * pod2usage has sections selector we can use and can parse right from file
 * app cli provide us filename
 r5489 at ruslan-zakirovs-computer:  ruz | 2008-05-24 19:21:33 +0400
 * move help and man options into Jifty::Script
 r5490 at ruslan-zakirovs-computer:  ruz | 2008-05-24 22:44:21 +0400
 * add support for message in print_help
 r5491 at ruslan-zakirovs-computer:  ruz | 2008-05-24 23:35:59 +0400
 * update scripts' pod
 ** bring everything to the same state
 r5501 at ruslan-zakirovs-computer:  ruz | 2008-06-05 23:59:41 +0400
 * update help in jifty commands
 r5502 at ruslan-zakirovs-computer:  ruz | 2008-06-06 00:07:22 +0400
 * use print_help in run and dies where error is caused be incorrect usage


Modified: jifty/trunk/lib/Jifty/Script.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Script.pm	(original)
+++ jifty/trunk/lib/Jifty/Script.pm	Thu Jun  5 19:42:31 2008
@@ -4,6 +4,7 @@
 
 use Jifty::Everything;
 Jifty::Everything->plugin_commands;
+use Pod::Usage;
 
 =head1 NAME
 
@@ -43,6 +44,17 @@
     return $self->SUPER::prepare(@_);
 }
 
+=head2 options
+
+=cut
+
+sub options {
+    return (
+     'h|help|?' => 'help',
+     'man'      => 'man',
+    );
+}
+
 =head2 alias
 
 The alias table lets users type C<fastcgi> in place of C<FastCGI>.
@@ -55,7 +67,38 @@
            )
 }
 
+=head2 print_help
+
+Prints out help for the package using pod2usage.
 
+If the user specified --help, prints a brief usage message
 
+If the user specified --man, prints out a manpage
+
+=cut
+
+sub print_help {
+    my $self = shift;
+    my $msg = shift;
+
+    $self->{'help'} = 1
+        if $msg && !( $self->{'help'} || $self->{'man'} );
+
+    my %opts = (
+        -exitval => $msg? 1: 0,
+        -input   => $self->filename,
+        -verbose => 99,
+        $msg? (-message => $msg): (),
+    );
+    # Option handling
+    pod2usage(
+        %opts,
+        -sections => 'NAME|SYNOPSIS',
+    ) if $self->{help};
+    pod2usage(
+        %opts,
+        -sections => '!METHODS',
+    ) if $self->{man};
+}
 
 1;

Modified: jifty/trunk/lib/Jifty/Script/Action.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Script/Action.pm	(original)
+++ jifty/trunk/lib/Jifty/Script/Action.pm	Thu Jun  5 19:42:31 2008
@@ -2,27 +2,23 @@
 use strict;
 
 package Jifty::Script::Action;
-use base qw/App::CLI::Command/;
-
-
+use base qw/Jifty::Script/;
 
 =head1 NAME
 
 Jifty::Script::Action - Add an action class to your Jifty application
 
-=head1 DESCRIPTION
-
-This creates a skeleton of a new action class for your jifty
-application, complete with a skeleton of a test suite for it,
-as well.
+=head1 SYNOPSIS
 
-=head1 API
+    jifty action --name NewAction
+    jifty action --help
+    jifty action --man
 
-=head2 options
+=head1 OPTIONS
 
 There are only two possible options to this script:
 
-=over
+=over 8
 
 =item --name NAME (required)
 
@@ -34,17 +30,35 @@
 going to write already exist.  Passing the --force flag will make it
 overwrite the files.
 
+=item B<--help>
+
+Print a brief help message and exits.
+
+=item B<--man>
+
+Prints the manual page and exits.
+
 =back
 
 =cut
 
 sub options {
-    (
-     'n|name=s' => 'name',
-     'force'    => 'force',
-    )
+    my $self = shift;
+    return (
+        $self->SUPER::options,
+        'n|name=s' => 'name',
+        'force'    => 'force',
+    );
 }
 
+=head1 DESCRIPTION
+
+This creates a skeleton of a new action class for your jifty
+application, complete with a skeleton of a test suite for it,
+as well.
+
+=head1 METHODS
+
 =head2 run
 
 Creates a skeleton file under C<lib/I<ApplicationClass>/Action/I<Action>>, as
@@ -54,10 +68,12 @@
 
 sub run {
     my $self = shift;
+
+    $self->print_help;
     
     my $action = $self->{name} || '';
-    die "You need to give your new action a --name\n"
-      unless $action =~ /\w+/;
+    $self->print_help("You need to give your new action a --name")
+        unless $action =~ /\w+/;
 
     Jifty->new( no_handle => 1 );
     my $root = Jifty::Util->app_root;

Modified: jifty/trunk/lib/Jifty/Script/Adopt.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Script/Adopt.pm	(original)
+++ jifty/trunk/lib/Jifty/Script/Adopt.pm	Thu Jun  5 19:42:31 2008
@@ -3,7 +3,7 @@
 use warnings;
 use strict;
 
-use base qw/App::CLI::Command/;
+use base qw/Jifty::Script/;
 
 use File::Copy ();
 use File::Spec ();
@@ -15,35 +15,59 @@
 
 Jifty::Script::Adopt - localize a stock jifty component
 
-=head1 DESCRIPTION
+=head1 SYNOPSIS
 
-Creates directories and copies files for you, launching $ENV{EDITOR} if
-it is defined.
+    jifty adopt web/templates/_elements/nav
+    jifty adopt --ls web/static/
+
+ Options:
+   --ls <path>        list components for adoption
+   --tree <path>      list components for adoption
+
+   --help             brief help message
+   --man              full documentation
+
+=head1 OPTIONS
+
+=over 8
+
+=item B<-l>, B<--ls> PATH
+
+Lists the contents of the stock components path.
+
+=item B<-t>, B<--tree> PATH
 
-=head2 options
+Lists the contents of the stock components path recursively.
 
-=over
+=item B<--help>
 
-=item --ls PATH
+Print a brief help message and exits.
 
-List the contents of the stock components path.
+=item B<--man>
+
+Prints the manual page and exits.
 
 =back
 
 =cut
 
 sub options {
-    (
-     'l|ls' => 'list',
-     't|tree' => 'tree',
+    my $self = shift;
+    return (
+        $self->SUPER::options,
+        'l|ls' => 'list',
+        't|tree' => 'tree',
     )
 }
 
-=head2 run
+=head1 DESCRIPTION
 
-  jifty adopt web/templates/_elements/nav
+Creates directories and copies files for you, launching $ENV{EDITOR} if
+it is defined.
+
+=head1 METHODS
 
-  jifty adopt --ls web/static/
+=head2 run
 
 =cut
 
@@ -51,6 +75,8 @@
     my $self = shift;
     my (@args) = @_;
 
+    $self->print_help();
+
     my $filename = shift(@args);
     $filename ||= '';
     my @parts = split(/[\/\\]/, $filename);

Modified: jifty/trunk/lib/Jifty/Script/App.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Script/App.pm	(original)
+++ jifty/trunk/lib/Jifty/Script/App.pm	Thu Jun  5 19:42:31 2008
@@ -2,7 +2,7 @@
 use strict;
 
 package Jifty::Script::App;
-use base qw(App::CLI::Command Class::Accessor::Fast);
+use base qw(Jifty::Script Class::Accessor::Fast);
 
 use File::Copy;
 use Jifty::Config;
@@ -16,26 +16,53 @@
 
 Jifty::Script::App - Create the skeleton of a Jifty application
 
-=head1 DESCRIPTION
+=head1 SYNOPSIS
 
-Creates a skeleton of a new Jifty application.  See
-L<Jifty::Manual::Tutorial> for an example of its use.
+  jifty --name MyApp  Creates an application
+
+ Options:
+   --name             applicaation name
+
+   --help             brief help message
+   --man              full documentation
+
+=head1 OPTIONS
+
+=over 8
+
+=item B<--name>
+
+Required option. It is the name of the application to create.
+Jifty will create a directory with that name, and place all of
+the files it creates inside that directory.
+
+=item B<--help>
+
+Print a brief help message and exits.
 
-=head2 options
+=item B<--man>
 
-This script only takes one option, C<--name>, which is required; it is
-the name of the application to create.  Jifty will create a directory
-with that name, and place all of the files it creates inside that
-directory.
+Prints the manual page and exits.
+
+=back
 
 =cut
 
 sub options {
-    (
-     'n|name=s' => 'name',
+    my $self = shift;
+    return (
+        $self->SUPER::options,
+        'n|name=s' => 'name',
     )
 }
 
+=head1 DESCRIPTION
+
+Creates a skeleton of a new Jifty application.  See
+L<Jifty::Manual::Tutorial> for an example of its use.
+
+=head1 METHODS
+
 =head2 run
 
 Create a directory for the application, a skeleton directory
@@ -48,13 +75,15 @@
 
     my $name = $self->{'name'};
     $name =~ s/::/-/g;
-    $self->prefix( $name); 
+    $self->prefix( $name ); 
 
-    unless ($self->prefix =~ /\w+/ ) { die "You need to give your new Jifty app a --name"."\n";}
+    $self->print_help;
+    unless ($self->prefix =~ /\w+/ ) {
+        $self->print_help("You need to give your new Jifty app a --name");
+    }
 
     # Turn my-app-name into My::App::Name.
 
-
     $self->mod_name (join ("::", split (/\-/, $self->prefix)));
     my $dist = $self->mod_name;
     $self->dist_name($self->prefix);

Modified: jifty/trunk/lib/Jifty/Script/Console.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Script/Console.pm	(original)
+++ jifty/trunk/lib/Jifty/Script/Console.pm	Thu Jun  5 19:42:31 2008
@@ -2,7 +2,7 @@
 use warnings;
 
 package Jifty::Script::Console;
-use base qw/App::CLI::Command/;
+use base qw/Jifty::Script/;
 use Devel::EvalContext;
 use Term::ReadLine;
 
@@ -10,6 +10,29 @@
 
 Jifty::Script::Console - A console for your Jifty application
 
+=head1 SYNOPSIS
+
+    jifty console
+    jifty console --help
+    jifty console --man
+
+=head1 OPTIONS
+
+This script has no specific options now except help.
+Maybe it will have some command lines options in the future.
+
+=over 8
+
+=item B<--help>
+
+Print a brief help message and exits.
+
+=item B<--man>
+
+Prints the manual page and exits.
+
+=back
+
 =head1 DESCRIPTION
 
 This script aims for developing purpose (or maintaining, if possible).
@@ -25,16 +48,7 @@
 
 =head1 METHODS
 
-=head2 options()
-
-Returns nothing. This script has no options now. Maybe it will have
-some command lines options in the future.
-
-=cut
-
-sub options { }
-
-=head2 run()
+=head2 run
 
 Creates a new console process.
 
@@ -42,6 +56,7 @@
 
 sub run {
     my $self = shift;
+    $self->print_help();
     Jifty->new();
     my $term = new Term::ReadLine 'Jifty Console';
     my $OUT = $term->OUT || \*STDOUT;

Modified: jifty/trunk/lib/Jifty/Script/Deps.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Script/Deps.pm	(original)
+++ jifty/trunk/lib/Jifty/Script/Deps.pm	Thu Jun  5 19:42:31 2008
@@ -2,7 +2,7 @@
 use strict;
 
 package Jifty::Script::Deps;
-use base qw/App::CLI::Command/;
+use base qw/Jifty::Script/;
 
 use Config;
 use File::Find::Rule;
@@ -16,34 +16,56 @@
 
 Jifty::Script::Deps - Looks for module dependencies and attempts to install them from CPAN
 
-=head1 METHODS
+=head1 SYNOPSIS
 
-=head2 options
+    jifty deps
+    jifty deps --setup
 
-Returns a hash of all the options this script takes. (See the usage message for details)
+  Options:
+    --setup        ... no description ...
 
-=cut
+    --help             brief help message
+    --man              full documentation
+
+=head1 OPTIONS
+
+=over 8
+
+=item B<--setup>
+
+... no description ...
+
+=item B<--help>
+
+Print a brief help message and exits.
+
+=item B<--man>
 
+Prints the manual page and exits.
+
+=back
+
+=cut
 
 sub options {
+    my $self = shift;
     return (
+        $self->SUPER::options,
         "setup"             => "setup_deps",
-        "help|?"            => "help",
     );
 }
 
-=head2 run
-
-Prints a help message if the users want it. If not, goes about its
-business.
+=head1 METHODS
 
-Sets up the environment, checks current database state, creates or deletes
-a database as necessary and then creates or updates your models' schema.
+=head2 run
 
 =cut
 
 sub run {
     my $self = shift;
+    
+    $self->print_help;
+    
     local     $ENV{'PERL_MM_USE_DEFAULT'} = 1;
     Jifty->new( no_handle => 1 );
 

Modified: jifty/trunk/lib/Jifty/Script/Env.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Script/Env.pm	(original)
+++ jifty/trunk/lib/Jifty/Script/Env.pm	Thu Jun  5 19:42:31 2008
@@ -3,7 +3,7 @@
 use warnings;
 use strict;
 
-use base qw/App::CLI::Command/;
+use base qw/Jifty::Script/;
 
 use Scalar::Util ();
 
@@ -14,15 +14,36 @@
 
 Jifty::Script::Env - access the Jifty environment
 
+=head1 SYNOPSIS
+
+    jifty env <Class> <method> [arguments]
+
+    jifty env  Util share_root
+    jifty env 'Util->share_root'
+    jifty env  Util.share_root
+
+=head1 OPTIONS
+
+This script has no specific options now. Maybe it will have
+some command lines options in the future.
+
+=over 8
+
+=item B<--help>
+
+Print a brief help message and exits.
+
+=item B<--man>
+
+Prints the manual page and exits.
+
+=back
+
 =head1 DESCRIPTION
 
 Loads Jifty and your configuration, allowing you to verify and examine
 your setup.
 
-=head2 run
-
-  jifty env <Class> <method> [arguments]
-
 Loads Jifty::Class and calls method on it, providing shortcuts for
 things like:
 
@@ -48,10 +69,14 @@
     my $self = shift;
     my (@args) = @_;
 
+    $self->print_help;
+
     Jifty->new();
 
     unless(@args) {
-        return($self->run('Jifty.config.stash'));
+        $self->run('Jifty.config.stash');
+        print "\nSee also `jifty env --help`\n";
+        return;
     }
 
     my ($class, $method, @and) = split(/(?:->?|\.)/, shift(@args));

Modified: jifty/trunk/lib/Jifty/Script/FastCGI.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Script/FastCGI.pm	(original)
+++ jifty/trunk/lib/Jifty/Script/FastCGI.pm	Thu Jun  5 19:42:31 2008
@@ -3,16 +3,54 @@
 
 
 package Jifty::Script::FastCGI;
-use base qw/App::CLI::Command/;
+use base qw/Jifty::Script/;
 
 use File::Basename;
 use CGI::Fast;
 
-
 =head1 NAME
 
 Jifty::Script::FastCGI - A FastCGI server for your Jifty application
 
+=head1 SYNOPSIS
+
+    AddHandler fastcgi-script fcgi
+    FastCgiServer /path/to/your/jifty/app/bin/jifty -initial-env JIFTY_COMMAND=fastcgi 
+
+  Options:
+    --maxrequests      maximum number of requests per process
+
+    --help             brief help message
+    --man              full documentation
+
+=head1 OPTIONS
+
+=over 8
+
+=item B<--maxrequests>
+
+Set maximum number of requests per process. Read also --man.
+
+=item B<--help>
+
+Print a brief help message and exits.
+
+=item B<--man>
+
+Prints the manual page and exits.
+
+=back
+
+=cut
+
+sub options {
+    my $self = shift;
+    return (
+        $self->SUPER::options,
+        'maxrequests=i' => 'maxrequests',
+    );
+}
+
 =head1 DESCRIPTION
 
 When you're ready to move up to something that can handle the increasing load your
@@ -68,15 +106,7 @@
 
 It may be possible to do this without using mod_rewrite.
 
-=head2 options
-
-=cut
-
-sub options {
-    (
-        'maxrequests=i' => 'maxrequests',
-    );
-}
+=head1 METHODS
 
 =head2 run
 
@@ -86,6 +116,9 @@
 
 sub run {
     my $self = shift;
+
+    $self->print_help;
+
     Jifty->new();
     my $conf = Jifty->config->framework('Web')->{'FastCGI'} || {};
     $self->{maxrequests} ||= $conf->{MaxRequests};

Modified: jifty/trunk/lib/Jifty/Script/Help.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Script/Help.pm	(original)
+++ jifty/trunk/lib/Jifty/Script/Help.pm	Thu Jun  5 19:42:31 2008
@@ -1,6 +1,6 @@
 package Jifty::Script::Help;
 use strict;
-use base qw( App::CLI::Command::Help );
+use base qw( Jifty::Script::Help );
 use File::Find qw(find);
 
 sub help_base {

Modified: jifty/trunk/lib/Jifty/Script/ModPerl2.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Script/ModPerl2.pm	(original)
+++ jifty/trunk/lib/Jifty/Script/ModPerl2.pm	Thu Jun  5 19:42:31 2008
@@ -6,10 +6,23 @@
 use Jifty::Everything;
 use CGI;
 
+# XXX: can we turn it into a command line script and at the same time use it as
+# as handler?
+
 =head1 NAME
 
 Jifty::Script::ModPerl2 - a ModPerl2 handler for your jifty app.
 
+=head1 SYNOPSIS
+
+    <VirtualHost *:80>
+        DocumentRoot /path/to/base/dir/of/app
+        SetHandler perl-script
+        PerlHandler Jifty::Script::ModPerl2
+    </VirtualHost>
+
+Not a command line script. Read --man for more info.
+
 =head1 DESCRIPTION
 
 This handler should be used with Apache2 and ModPerl2.  It requires the
@@ -29,6 +42,8 @@
 
 TODO: This should be set up to serv the static files without mod_perl.
 
+=head1 METTHODS
+
 =head2 handler
 
 The mod_perl handler for the app
@@ -52,7 +67,6 @@
     ##
     # Oll Korrect
     return Apache2::Const::OK;
-
 }
 
 1;

Modified: jifty/trunk/lib/Jifty/Script/Model.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Script/Model.pm	(original)
+++ jifty/trunk/lib/Jifty/Script/Model.pm	Thu Jun  5 19:42:31 2008
@@ -2,48 +2,66 @@
 use strict;
 
 package Jifty::Script::Model;
-use base qw/App::CLI::Command/;
-
-
+use base qw/Jifty::Script/;
 
 =head1 NAME
 
 Jifty::Script::Model - Add a model class to your Jifty application
 
-=head1 DESCRIPTION
+=head1 SYNOPSIS
 
-This creates a skeleton of a new model class for your jifty
-application, complete with a skeleton of a test suite for it, as well.
+    jifty model --name MyFirstModel
+    jifty model --name MyFirstModel --force
 
-=head1 API
+  Options:
+    --name <name>      name of the model
+    --force            overwrite files
 
-=head2 options
+    --help             brief help message
+    --man              full documentation
 
-There are only two possible options to this script:
+=head1 OPTIONS
 
-=over
+=over 8
 
-=item --name NAME (required)
+=item B<--name> NAME (required)
 
 Name of the model class.
 
-=item --force
+=item B<--force>
 
 By default, this will stop and warn you if any of the files it is
 going to write already exist.  Passing the --force flag will make it
 overwrite the files.
 
+=item B<--help>
+
+Print a brief help message and exits.
+
+=item B<--man>
+
+Prints the manual page and exits.
+
 =back
 
 =cut
 
 sub options {
-    (
-     'n|name=s' => 'name',
-     'force' => 'force',
+    my $self = shift;
+    return (
+        $self->SUPER::options,
+        'n|name=s' => 'name',
+        'force' => 'force',
     )
 }
 
+=head1 DESCRIPTION
+
+This creates a skeleton of a new model class for your jifty
+application, complete with a skeleton of a test suite for it, as well.
+
+=head1 METHODS
+
 =head2 run
 
 Creates a skeleton file under C<lib/I<ApplicationClass>/Model/I<Model>>, as
@@ -54,8 +72,10 @@
 sub run {
     my $self = shift;
     
+    $self->print_help;
+
     my $model = $self->{name} || '';
-    die "You need to give your new model a --name\n"
+    $self->print_help("You need to give your new model a --name")
       unless $model =~ /\w+/;
 
     Jifty->new( no_handle => 1 );

Modified: jifty/trunk/lib/Jifty/Script/Plugin.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Script/Plugin.pm	(original)
+++ jifty/trunk/lib/Jifty/Script/Plugin.pm	Thu Jun  5 19:42:31 2008
@@ -2,7 +2,7 @@
 use strict;
 
 package Jifty::Script::Plugin;
-use base qw(App::CLI::Command Class::Accessor::Fast);
+use base qw(Jifty::Script Class::Accessor::Fast);
 
 use File::Copy;
 use Jifty::Config;
@@ -16,11 +16,21 @@
 
 Jifty::Script::Plugin - Create the skeleton of a Jifty plugin
 
+=head1 SYNOPSIS
+    
+    jifty plugin --name NewPlugin
+    jifty plugin --help
+    jifty plugin --man
+
 =head1 DESCRIPTION
 
 Creates a skeleton of a new L<Jifty::Plugin>.
 
-=head2 options
+=head1 OPTIONS
+
+=over 8
+
+=item --name
 
 This script only takes one option, C<--name>, which is required; it is
 the name of the plugin to create; this will be prefixed with
@@ -28,14 +38,28 @@
 that name, and place all of the files it creates inside that
 directory.
 
+=item B<--help>
+
+Print a brief help message and exits.
+
+=item B<--man>
+
+Prints the manual page and exits.
+
+=back
+
 =cut
 
 sub options {
-    (
-     'n|name=s' => 'name',
+    my $self = shift;
+    return (
+        $self->SUPER::options,
+        'n|name=s' => 'name',
     )
 }
 
+=head1 METHODS
+
 =head2 run
 
 Create a directory for the plugin, a skeleton directory structure, and
@@ -45,6 +69,7 @@
 
 sub run {
     my $self = shift;
+    $self->print_help();
 
     $self->prefix( $self->{name} ||''); 
 
@@ -145,6 +170,4 @@
     );
 }
 
-
 1;
-

Modified: jifty/trunk/lib/Jifty/Script/Po.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Script/Po.pm	(original)
+++ jifty/trunk/lib/Jifty/Script/Po.pm	Thu Jun  5 19:42:31 2008
@@ -2,7 +2,7 @@
 use strict;
 
 package Jifty::Script::Po;
-use base qw(App::CLI::Command Class::Accessor::Fast);
+use base qw(Jifty::Script Class::Accessor::Fast);
 
 use Pod::Usage;
 use File::Copy ();
@@ -27,13 +27,13 @@
 =cut
 
 sub options {
+    my $self = shift;
     return (
+        $self->SUPER::options,
         'l|language=s' => 'language',
         'dir=s@'       => 'directories',
         'js'           => 'js',
-        'help|?'       => "help",
-        'man'          => "man",
-    );
+    )
 }
 
 

Modified: jifty/trunk/lib/Jifty/Script/Repl.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Script/Repl.pm	(original)
+++ jifty/trunk/lib/Jifty/Script/Repl.pm	Thu Jun  5 19:42:31 2008
@@ -2,13 +2,36 @@
 use warnings;
 
 package Jifty::Script::Repl;
-use base qw/App::CLI::Command/;
+use base qw/Jifty::Script/;
 use Devel::REPL::Script;
 
 =head1 NAME
 
 Jifty::Script::Repl - A REPL for your Jifty application
 
+=head1 SYNOPSIS
+
+    jifty repl
+    jifty repl --help
+    jifty repl --man
+
+=head1 OPTIONS
+
+This script has no specific options now except help.
+Maybe it will have some command lines options in the future.
+
+=over 8
+
+=item B<--help>
+
+Print a brief help message and exits.
+
+=item B<--man>
+
+Prints the manual page and exits.
+
+=back
+
 =head1 DESCRIPTION
 
 This gives you a L<Devel::REPL> for your Jifty application. L<Devel::REPL> is a
@@ -20,15 +43,6 @@
 
 =head1 METHODS
 
-=head2 options()
-
-Returns nothing. This script has no options now. Maybe it will have
-some command lines options in the future.
-
-=cut
-
-sub options { }
-
 =head2 run()
 
 Creates a L<Devel::REPL> object and runs it.
@@ -37,6 +51,7 @@
 
 sub run {
     my $self = shift;
+    $self->print_help();
     Jifty->new();
     Devel::REPL::Script->new->run();
 }

Modified: jifty/trunk/lib/Jifty/Script/Schema.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Script/Schema.pm	(original)
+++ jifty/trunk/lib/Jifty/Script/Schema.pm	Thu Jun  5 19:42:31 2008
@@ -2,34 +2,122 @@
 use strict;
 
 package Jifty::Script::Schema;
-use base qw/App::CLI::Command/;
+use base qw/Jifty::Script/;
 
-use Pod::Usage;
 use version;
 use Jifty::DBI::SchemaGenerator;
 use Jifty::Config;
 use Jifty::Schema;
 
-### Help is below in __DATA__ section
+=head1 NAME
+
+Jifty::Script::Schema - Create SQL to update or create your Jifty app's tables
+
+=head1 SYNOPSIS
+
+  jifty schema --setup      Creates or updates your application's database tables
+
+ Options:
+   --print            Print SQL, rather than executing commands
+
+   --setup            Upgrade or install the database, creating it if need be
+   --create-database  Only creates the database
+   --drop-database    Drops the database
+   --ignore-reserved-words   Ignore any SQL reserved words in schema definition
+
+   --help             brief help message
+   --man              full documentation
+
+=head1 OPTIONS
+
+=over 8
+
+=item B<--print>
+
+Rather than actually running the database create/update/drop commands,
+Prints the commands to standard output
+
+=item B<--create-database>
+
+Send a CREATE DATABASE command.  Note that B<--setup>, below, will
+automatically send a CREATE DATABASE if it needs one.  This option is
+useful if you wish to create the database without creating any tables
+in it.
+
+=item B<--drop-database>
+
+Send a DROP DATABASE command.  Use this in conjunction with B<--setup>
+to wipe and re-install the database.
+
+=item B<--setup>
+
+Actually set up your app's tables.  This creates the database if need
+be, and runs any commands needed to bring the tables up to date; these
+may include CREATE TABLE or ALTER TABLE commands.  This option is
+assumed if the database does not exist, or the database version is not
+the same as the application's version.
+
+=item B<--ignore-reserved-words>
 
-=head2 options
+Ignore any SQL reserved words used in table or column deffinitions, if
+this option is not used and a reserved word is found it will cause an error.
+
+=item B<--help>
 
-Returns a hash of all the options this script takes. (See the usage message for details)
+Print a brief help message and exits.
+
+=item B<--man>
+
+Prints the manual page and exits.
+
+=back
 
 =cut
 
 sub options {
+    my $self = shift;
     return (
+        $self->SUPER::options,
         "setup"                 => "setup_tables",
         "print|p"               => "print",
         "create-database|c"     => "create_database",
         "ignore-reserved-words" => "ignore_reserved",
         "drop-database"         => "drop_database",
-        "help|?"                => "help",
-        "man"                   => "man"
     );
 }
 
+=head1 DESCRIPTION
+
+Looks for all model classes of your Jifty application and generates
+SQL statements to create or update database tables for all of the
+models.  It either prints the SQL to standard output (B<--print>) or
+actually issues the C<CREATE TABLE> or C<ALTER TABLE> statements on
+Jifty's database.
+
+(Note that even if you are just displaying the SQL, you need to have
+correctly configured your Jifty database in
+I<ProjectRoot>C</etc/config.yml>, because the SQL generated may depend
+on the database type.)
+
+By default checks for SQL reserved words in your table names and
+column definitions, throwing an error if any are found.  
+
+If you want to permanently turn this behaviour off you can set
+CheckSchema to 0 in the database section of your applications config
+file.
+
+=head1 BUGS
+
+Due to limitations of L<DBIx::DBSchema>, this probably only works with
+PostgreSQL, MySQL and SQLite.
+
+It is possible that some of this functionality should be rolled into
+L<Jifty::DBI::SchemaGenerator>
+
+=cut
+
+=head1 METHODS
+
 =head2 run
 
 Prints a help message if the users want it. If not, goes about its
@@ -98,26 +186,6 @@
     return $self->{'SCHEMA'};
 }
 
-=head2 print_help
-
-Prints out help for the package using pod2usage.
-
-If the user specified --help, prints a brief usage message
-
-If the user specified --man, prints out a manpage
-
-=cut
-
-sub print_help {
-    my $self = shift;
-
-    # Option handling
-    my $docs = \*DATA;
-    pod2usage( -exitval => 1, -input => $docs ) if $self->{help};
-    pod2usage( -exitval => 0, -verbose => 2, -input => $docs )
-        if $self->{man};
-}
-
 =head2 probe_database_existence
 
 Probes our database to see if it exists and is up to date.
@@ -626,98 +694,3 @@
 }
 
 1;
-
-__DATA__
-
-=head1 NAME
-
-Jifty::Script::Schema - Create SQL to update or create your Jifty app's tables
-
-=head1 SYNOPSIS
-
-  jifty schema --setup      Creates or updates your application's database tables
-
- Options:
-   --print            Print SQL, rather than executing commands
-
-   --setup            Upgrade or install the database, creating it if need be
-   --create-database  Only creates the database
-   --drop-database    Drops the database
-   --ignore-reserved-words   Ignore any SQL reserved words in schema definition
-
-   --help             brief help message
-   --man              full documentation
-
-=head1 OPTIONS
-
-=over 8
-
-=item B<--print>
-
-Rather than actually running the database create/update/drop commands,
-Prints the commands to standard output
-
-=item B<--create-database>
-
-Send a CREATE DATABASE command.  Note that B<--setup>, below, will
-automatically send a CREATE DATABASE if it needs one.  This option is
-useful if you wish to create the database without creating any tables
-in it.
-
-=item B<--drop-database>
-
-Send a DROP DATABASE command.  Use this in conjunction with B<--setup>
-to wipe and re-install the database.
-
-=item B<--setup>
-
-Actually set up your app's tables.  This creates the database if need
-be, and runs any commands needed to bring the tables up to date; these
-may include CREATE TABLE or ALTER TABLE commands.  This option is
-assumed if the database does not exist, or the database version is not
-the same as the application's version.
-
-=item B<--ignore-reserved-words>
-
-Ignore any SQL reserved words used in table or column deffinitions, if
-this option is not used and a reserved word is found it will cause an error.
-
-=item B<--help>
-
-Print a brief help message and exits.
-
-=item B<--man>
-
-Prints the manual page and exits.
-
-=back
-
-=head1 DESCRIPTION
-
-Looks for all model classes of your Jifty application and generates
-SQL statements to create or update database tables for all of the
-models.  It either prints the SQL to standard output (B<--print>) or
-actually issues the C<CREATE TABLE> or C<ALTER TABLE> statements on
-Jifty's database.
-
-(Note that even if you are just displaying the SQL, you need to have
-correctly configured your Jifty database in
-I<ProjectRoot>C</etc/config.yml>, because the SQL generated may depend
-on the database type.)
-
-By default checks for SQL reserved words in your table names and
-column definitions, throwing an error if any are found.  
-
-If you want to permanently turn this behaviour off you can set
-CheckSchema to 0 in the database section of your applications config
-file.
-
-=head1 BUGS
-
-Due to limitations of L<DBIx::DBSchema>, this probably only works with
-PostgreSQL, MySQL and SQLite.
-
-It is possible that some of this functionality should be rolled into
-L<Jifty::DBI::SchemaGenerator>
-
-=cut

Modified: jifty/trunk/lib/Jifty/Script/Script.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Script/Script.pm	(original)
+++ jifty/trunk/lib/Jifty/Script/Script.pm	Thu Jun  5 19:42:31 2008
@@ -2,21 +2,22 @@
 use strict;
 
 package Jifty::Script::Script;
-use base qw/ App::CLI::Command /;
+use base qw/ Jifty::Script /;
 
 =head1 NAME
 
 Jifty::Script::Script - Add a new Jifty script to your Jifty application
 
-=head1 DESCRIPTION
-
-This creates a skeleton of a new script file for your Jifty application. Often it such a script is needed for cron jobs, annual maintenance work, and any other server-side activity that would benefit from a command-line script.
+=head1 SYNOPSIS
 
-=head1 API
+    jifty script --name my_new_script
+    jifty script --name my_new_script --force
+    jifty script --help
+    jifty script --man
 
-=head2 options
+=head1 OPTIONS
 
-=over
+=over 8
 
 =item --name NAME (required)
 
@@ -26,17 +27,33 @@
 
 By default, this will stop and warn you if any of the files it is going to write already exist. Passing the --force flag will make it overwrite the files.
 
+=item B<--help>
+
+Print a brief help message and exits.
+
+=item B<--man>
+
+Prints the manual page and exits.
+
 =back
 
 =cut
 
 sub options {
-    (
+    my $self = shift;
+    return (
+        $self->SUPER::options,
         'n|name=s' => 'name',
         'force'    => 'force',
     )
 }
 
+=head1 DESCRIPTION
+
+This creates a skeleton of a new script file for your Jifty application. Often such a script is needed for cron jobs, annual maintenance work, and any other server-side activity that would benefit from a command-line script.
+
+=head1 METHODS
+
 =head2 run
 
 Creates a skeleton file under C<bin/I<script>>.
@@ -48,8 +65,10 @@
 sub run {
     my $self = shift;
 
+    $self->print_help;
+
     my $script = $self->{name};
-    die "You need to give your new script a --name\n"
+    $self->print_help("You need to give your new script a --name")
         unless defined $script;
 
     Jifty->new( no_handle => 1 );

Modified: jifty/trunk/lib/Jifty/Script/Server.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Script/Server.pm	(original)
+++ jifty/trunk/lib/Jifty/Script/Server.pm	Thu Jun  5 19:42:31 2008
@@ -2,7 +2,7 @@
 use strict;
 
 package Jifty::Script::Server;
-use base qw/App::CLI::Command/;
+use base qw/Jifty::Script/;
 
 # XXX: if test::builder is not used, sometimes connection is not
 # properly closed, causing the client to wait for the content for a
@@ -26,31 +26,62 @@
 
 Jifty::Script::Server - A standalone webserver for your Jifty application
 
-=head1 DESCRIPTION
+=head1 SYNOPSIS
 
-When you're getting started with Jifty, this is the server you
-want. It's lightweight and easy to work with.
+    jifty server
+    jifty server --port 6666
+    jifty server --stop
+
+=head1 OPTIONS
+
+=over 8
+
+=item --port
+
+The port to run the server on. Overrides the port in the config file, if it is
+set there. The default port is 8888.
+
+=item --stop
+
+Stops the server.
+
+=item --sigready
+
+=item --quiet
 
-=head1 API
+=item --dbiprof
 
-=head2 options
+=item B<--help>
 
-The server takes only one option, C<--port>, the port to run the
-server on.  This is overrides the port in the config file, if it is
-set there.  The default port is 8888.
+Print a brief help message and exits.
+
+=item B<--man>
+
+Prints the manual page and exits.
+
+=back
 
 =cut
 
 sub options {
-    (
-     'p|port=s'   => 'port',
-     'stop'       => 'stop',
-     'sigready=s' => 'sigready',
-     'quiet'      => 'quiet',
-     'dbiprof'    => 'dbiprof',
+    my $self = shift;
+    return (
+        $self->SUPER::options,
+        'p|port=s'   => 'port',
+        'stop'       => 'stop',
+        'sigready=s' => 'sigready',
+        'quiet'      => 'quiet',
+        'dbiprof'    => 'dbiprof',
     )
 }
 
+=head1 DESCRIPTION
+
+When you're getting started with Jifty, this is the server you
+want. It's lightweight and easy to work with.
+
+=head1 METHODS
+
 =head2 run
 
 C<run> takes no arguments, but starts up a Jifty server process for
@@ -60,6 +91,7 @@
 
 sub run {
     my $self = shift;
+    $self->print_help;
     Jifty->new();
 
     if ($self->{stop}) {


More information about the Jifty-commit mailing list