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

Jifty commits jifty-commit at lists.jifty.org
Tue Sep 22 19:41:01 EDT 2009


Author: sunnavy
Date: Tue Sep 22 19:41:00 2009
New Revision: 7496

Modified:
   jifty/trunk/bin/jifty
   jifty/trunk/lib/Jifty/Script.pm
   jifty/trunk/lib/Jifty/Script/Help.pm

Log:
revert the dirty hack of jifty help speedup

Modified: jifty/trunk/bin/jifty
==============================================================================
--- jifty/trunk/bin/jifty	(original)
+++ jifty/trunk/bin/jifty	Tue Sep 22 19:41:00 2009
@@ -1,39 +1,16 @@
 #!/usr/bin/env perl
 use warnings;
 use strict;
+use UNIVERSAL::require;
 
 BEGIN {
-
-    # `use Jifty::Everything' is time-consuming,
-    # when people just want to read the help message, waiting sucks.
-    # on my machine, this is 4.5x faster or so, from 0.7s to 0.15s
-    require Jifty::Script;
-    if (
-        @ARGV == 0
-        || ( $ARGV[0] eq 'help' )
-        && (
-            @ARGV == 1 || grep { lc $ARGV[1] eq lc $_ } @Jifty::Script::CORE_CMDS,
-            @Jifty::Script::CORE_MAN,
-        )
-      )
-    {
-
-   # only_core is to tell Jifty::Script not to use Jifty::Everything to find all
-   # the cmds
-        Jifty::Script->import( only_core => 1 );
-    }
-    else {
-        no warnings 'once';
-        require UNIVERSAL::require;
-        Jifty::Util->require or die $UNIVERSAL::require::ERROR;
-        my $root = Jifty::Util->app_root( quiet => 1 );
-        unshift @INC, "$root/lib" if ($root);
-
-        require Jifty;
-        Jifty::Script->import;
-    }
+    Jifty::Util->require or die $UNIVERSAL::require::ERROR;
+    my $root = Jifty::Util->app_root(quiet => 1);
+    unshift @INC, "$root/lib" if ($root);
 }
 
+use Jifty;
+use Jifty::Script;
 
 local $SIG{INT} = sub { warn "Stopped\n"; exit; };
 Jifty::Script->dispatch();

Modified: jifty/trunk/lib/Jifty/Script.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Script.pm	(original)
+++ jifty/trunk/lib/Jifty/Script.pm	Tue Sep 22 19:41:00 2009
@@ -2,21 +2,10 @@
 use App::CLI;
 use base qw/App::CLI App::CLI::Command Jifty::Object/;
 
+use Jifty::Everything;
+Jifty::Everything->plugin_commands;
 use Pod::Usage;
 
-our @CORE_CMDS = qw/action adopt app env fastcgi help modperl2 model
-  plugin po schema script server/;
-our @CORE_MAN = qw/
-  AccessControl         Glossary              Tutorial
-  AccessControl_zhtw    JavaScript            TutorialRest
-  Actions               JavaScript_zhtw       Tutorial_de
-  Actions_zhtw          Models                Tutorial_ja
-  Continuations         ObjectModel           Tutorial_zhtw
-  Cookbook              PageRegions           Upgrading
-  Deploying             Preload               UsingCSSandJS
-  Deploying_zhtw        RequestHandling       jQueryMigrationGuide
-  FAQ                   Style                /;
-
 =head1 NAME
 
 Jifty::Script - Base class for all bin/jifty commands
@@ -116,13 +105,4 @@
     ) if $self->{man};
 }
 
-sub import {
-    my $self = shift;
-    my %args = @_;
-    unless ( $args{only_core} ) {
-        require Jifty::Everything;
-        Jifty::Everything->plugin_commands;
-    }
-}
-
 1;

Modified: jifty/trunk/lib/Jifty/Script/Help.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Script/Help.pm	(original)
+++ jifty/trunk/lib/Jifty/Script/Help.pm	Tue Sep 22 19:41:00 2009
@@ -3,37 +3,6 @@
 use base qw( App::CLI::Command::Help Jifty::Script );
 use File::Find qw(find);
 
-sub run {
-    my $self   = shift;
-    my @topics = @_;
-
-    push @topics, 'commands' unless (@topics);
-
-    foreach my $topic (@topics) {
-        if ( $topic eq 'commands' ) {
-            $self->brief_usage($_) for $self->app->files;
-        }
-        elsif ( grep { $topic eq $_ } @Jifty::Script::CORE_CMDS ) {
-            # to find usage of a CMD, App::CLI will require the CMD.pm first
-            # that's too heavy for us because some CMD.pm `use Jifty', 
-            # which `use Jifty::Everything'!
-            my $file = $INC{'Jifty/Script/Help.pm'};
-            $file =~ s/Help(?=\.pm$)/ucfirst $topic/e;
-
-            open my $fh, '<:utf8', $file or die $!;
-            require Pod::Simple::Text;
-            my $parser = Pod::Simple::Text->new;
-            my $buf;
-            $parser->output_string( \$buf );
-            $parser->parse_file($fh);
-            print $self->loc_text($buf);
-        }
-        else {
-            $self->SUPER::run($topic);
-        }
-    }
-}
-
 sub help_base {
     return "Jifty::Manual";
 }


More information about the Jifty-commit mailing list