[Bps-public-commit] r18908 - in Shipwright/trunk/lib/Shipwright: Script

sunnavy at bestpractical.com sunnavy at bestpractical.com
Sun Mar 22 04:31:36 EDT 2009


Author: sunnavy
Date: Sun Mar 22 04:31:36 2009
New Revision: 18908

Modified:
   Shipwright/trunk/lib/Shipwright/Script.pm
   Shipwright/trunk/lib/Shipwright/Script/Create.pm
   Shipwright/trunk/lib/Shipwright/Script/Defaultbranch.pm
   Shipwright/trunk/lib/Shipwright/Script/Delete.pm
   Shipwright/trunk/lib/Shipwright/Script/Flags.pm
   Shipwright/trunk/lib/Shipwright/Script/Import.pm
   Shipwright/trunk/lib/Shipwright/Script/Ktf.pm
   Shipwright/trunk/lib/Shipwright/Script/List.pm
   Shipwright/trunk/lib/Shipwright/Script/Maintain.pm
   Shipwright/trunk/lib/Shipwright/Script/Relocate.pm
   Shipwright/trunk/lib/Shipwright/Script/Rename.pm
   Shipwright/trunk/lib/Shipwright/Script/Update.pm

Log:
update the way we output in scripts: using $self->log

Modified: Shipwright/trunk/lib/Shipwright/Script.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Script.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Script.pm	Sun Mar 22 04:31:36 2009
@@ -43,7 +43,7 @@
         $ARGV[0] = 'help';
     }
     elsif ( $ARGV[0] =~ /^(-v|--version|version)$/ ) {
-        print "This is Shipwright, version $Shipwright::VERSION\n";
+        $self->log->fatal( "This is Shipwright, version $Shipwright::VERSION" );
         exit 0;
     }
 

Modified: Shipwright/trunk/lib/Shipwright/Script/Create.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Script/Create.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Script/Create.pm	Sun Mar 22 04:31:36 2009
@@ -14,7 +14,7 @@
 
     my $shipwright = Shipwright->new( repository => $self->repository, );
     $shipwright->backend->initialize();
-    print "created with success\n";
+    $self->log->fatal( 'created with success' );
 }
 
 1;

Modified: Shipwright/trunk/lib/Shipwright/Script/Defaultbranch.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Script/Defaultbranch.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Script/Defaultbranch.pm	Sun Mar 22 04:31:36 2009
@@ -25,7 +25,8 @@
         @{ $branches->{$name} } =
           ( $default, grep { $_ ne $default } @{ $branches->{$name} } );
         $shipwright->backend->branches($branches);
-        print "set default branch for $name with success, now it's $default\n";
+        $self->log->fatal(
+            "set default branch for $name with success, now it's $default");
     }
     else {
         confess "$name doesn't have branches $default.

Modified: Shipwright/trunk/lib/Shipwright/Script/Delete.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Script/Delete.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Script/Delete.pm	Sun Mar 22 04:31:36 2009
@@ -55,13 +55,13 @@
     }
 
     if ( $self->check_only ) {
-        print "dists to be deleted are: @names\n";
+        $self->log->info( "dists to be deleted are: @names" );
     }
     else {
         for my $name (@names) {
             $shipwright->backend->trim( name => $name );
         }
-        print "deleted @names with success\n";
+        $self->log->fatal( "deleted @names with success" );
     }
 
 }

Modified: Shipwright/trunk/lib/Shipwright/Script/Flags.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Script/Flags.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Script/Flags.pm	Sun Mar 22 04:31:36 2009
@@ -26,7 +26,7 @@
     confess "need name arg\n" unless $name;
 
     if ( $name =~ /^__/ ) {
-        print "$name can't start as __\n";
+        $self->log->fatal( "$name can't start as __" );
         return;
     }
 
@@ -83,25 +83,26 @@
     my $changed;
     $changed = 1 if $self->add || $self->delete || $self->set;
 
+    my $flags_info;
     if ( $self->mandatory ) {
-        print "set mandatory flags with success\n" if $changed;
-        print "mandatory flags of $name is ";
+        $self->log->fatal( 'set mandatory flags with success' ) if $changed;
         if ( @{ $flags->{__mandatory}{$name} || [] } ) {
-            print join( ', ', @{ $flags->{__mandatory}{$name} } ) . "\n";
+            $flags_info = join ', ', @{ $flags->{__mandatory}{$name} };
         }
         else {
-            print "*nothing*\n";
+            $flags_info = '*nothing*';
         }
+        $self->log->fatal( "mandatory flags of $name is $flags_info" );
     }
     else {
-        print "set flags with success\n" if $changed;
-        print "flags of $name is ";
+        $self->log->fatal( 'set flags with success' ) if $changed;
         if ( @{ $flags->{$name} || [] } ) {
-            print join( ', ', @{ $flags->{$name} } ) . "\n";
+            $flags_info =  join ', ', @{ $flags->{$name} };
         }
         else {
-            print "*nothing*\n";
+            $flags_info = '*nothing*';
         }
+        $self->log->fatal( "flags of $name is $flags_info" );
     }
 
 }

Modified: Shipwright/trunk/lib/Shipwright/Script/Import.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Script/Import.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Script/Import.pm	Sun Mar 22 04:31:36 2009
@@ -86,7 +86,7 @@
 
     if ( $self->extra_tests ) {
 
-        print "going to import extra_tests\n";
+        $self->log->info( 'going to import extra_tests' );
         $shipwright->backend->import(
             source       => $source,
             comment      => 'import extra tests',
@@ -94,7 +94,7 @@
         );
     }
     elsif ( $self->test_script ) {
-        print "going to import test_script\n";
+        $self->log->info('going to import test_script');
         $shipwright->backend->test_script( source => $source );
     }
     else {
@@ -203,6 +203,7 @@
             my $branches =
               Shipwright::Util::LoadFile( $shipwright->source->branches_path );
 
+            $self->log->fatal( "importing $name" );
             $shipwright->backend->import(
                 source  => $source,
                 comment => $self->comment || 'import ' . $source,
@@ -245,7 +246,7 @@
 
     }
 
-    print "imported with success\n";
+    $self->log->fatal( 'imported with success' );
 
 }
 
@@ -293,7 +294,7 @@
                         next;
                     }
 
-                    print "importing $name: ";
+                    $self->log->fatal( "importing $name" );
                     my $s = catdir( $dir, $name );
 
                     my $script_dir;
@@ -351,7 +352,7 @@
 
     my @commands;
     if ( -f catfile( $source_dir, 'Build.PL' ) ) { # &&  $source_dir !~ /Module-Build/ ) { # M::B should be bootstrapped with MakeMaker
-        print "detected Module::Build build system\n";
+        $self->log->info( 'detected Module::Build build system' );
         @commands = (
             'configure: %%PERL%% %%MODULE_BUILD_BEFORE_BUILD_PL%% Build.PL --install_base=%%INSTALL_BASE%%',
             'make: %%PERL%% %%MODULE_BUILD_BEFORE_BUILD%% Build',
@@ -361,7 +362,7 @@
         );
     }
     elsif ( -f catfile( $source_dir, 'Makefile.PL' ) ) {
-        print "detected ExtUtils::MakeMaker build system or alike\n";
+        $self->log->info( 'detected ExtUtils::MakeMaker build system or alike' );
         @commands = (
             'configure: %%PERL%% Makefile.PL LIB=%%INSTALL_BASE%%/lib/perl5/ PREFIX=%%INSTALL_BASE%% %%MAKEMAKER_CONFIGURE_EXTRA%%',
             'make: %%MAKE%%',
@@ -371,7 +372,7 @@
         );
     }
     elsif ( -f catfile( $source_dir, 'configure' ) ) {
-        print "detected autoconf build system\n";
+        $self->log->info( 'detected autoconf build system' );
         @commands = (
             'configure: ./configure --prefix=%%INSTALL_BASE%%',
             'make: %%MAKE%%',
@@ -381,9 +382,10 @@
     }
     else {
         my ($name) = $source_dir =~ /([-\w.]+)$/;
-        print "unknown build system for this dist; you MUST manually edit\n";
-        print "/scripts/$name/build or provide a build.pl file or this dist\n";
-        print "will not be built!\n";
+        $self->log->warn(<<EOF);
+unknown build system for this dist; you MUST manually edit /scripts/$name/build 
+or provide a build.pl file or this dist will not be built!
+EOF
         $self->log->warn("I have no idea how to build this distribution");
 
         # stub build file to provide the user something to go from

Modified: Shipwright/trunk/lib/Shipwright/Script/Ktf.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Script/Ktf.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Script/Ktf.pm	Sun Mar 22 04:31:36 2009
@@ -46,14 +46,15 @@
     my $name = shift;
 
     if ( $self->delete ) {
-        print "deleted known test failure for $name\n";
+        $self->log->fatal( "deleted known test failure for $name" );
     }
     else {
         if ( defined $self->set ) {
-            print "set known test failure condition for $name with success\n";
+            $self->log->fatal(
+                "set known test failure condition for $name with success");
         }
 
-        print 'the condition is: ' . ( $ktf->{$name} || 'undef' ) . "\n";
+        $self->log->info( 'the condition is: ' . ( $ktf->{$name} || 'undef' ) );
     }
 }
 

Modified: Shipwright/trunk/lib/Shipwright/Script/List.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Script/List.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Script/List.pm	Sun Mar 22 04:31:36 2009
@@ -103,63 +103,74 @@
         }
 
         if ($flip) {
-            print $name, ': ', "\n";
-            print ' ' x 4 . 'version: ';
+            $self->log->fatal( $name, ':' );
+            my $version_info;
             if ( ref $versions->{$name} ) {
 
                 if ( $name =~ /^cpan-/ ) {
-                    print $versions->{$name}{'vendor'}, "\n";
+                    $version_info = $versions->{$name}{'vendor'};
                 }
                 else {
-                    print "\n";
+                    $version_info = "\n";
                     for my $branch ( keys %{ $versions->{$name} } ) {
-                        print ' ' x 8, $branch, ': ',
-                          $versions->{$name}{$branch} || '', "\n";
+                        $version_info .= ' ' x 8 .
+                          $branch . ': ' . $versions->{$name}{$branch}
+                          || '' . "\n";
                     }
+                    chomp $version_info;
                 }
             }
             else {
-                print $versions->{$name} || '', "\n";
+                $version_info = $versions->{$name} || '';
             }
+            $self->log->fatal( ' ' x 4 . 'version: ' . $version_info );
 
-            print ' ' x 4 . 'from: ';
+            my $from_info;
             if ( ref $source->{$name} ) {
-                print "\n";
+                $from_info = "\n";
                 for my $branch ( keys %{ $source->{$name} } ) {
-                    print ' ' x 8, $branch, ': ',
-                      $source->{$name}{$branch} || '', "\n";
+                    $from_info .= ' ' x 8 . $branch .
+                      ': ' . $source->{$name}{$branch} || '' . "\n";
                 }
+                chomp $from_info;
             }
             else {
-                print $source->{$name} || 'CPAN', "\n",;
+                $from_info = $source->{$name} || 'CPAN';
             }
+            $self->log->fatal( ' ' x 4 . 'from: ' . $from_info );
 
-            print ' ' x 4 . 'references: ',
-              defined $refs->{$name} ? $refs->{$name} : 'unknown', "\n";
+            $self->log->fatal( ' ' x 4 . 'references: ',
+              defined $refs->{$name} ? $refs->{$name} : 'unknown' );
 
             if ( $self->with_latest_version ) {
-                print ' ' x 4, 'latest_version: ';
+                my $latest_version_info;
                 if ( ref $source->{$name} ) {
-                    print "\n";
+                    $latest_version_info = "\n";
                     for my $branch ( keys %{ $source->{$name} } ) {
-                        print ' ' x 8, $branch, ': ',
-                          $latest_version->{$name}{$branch} || 'unknown', "\n";
+                        $latest_version_info .=
+                            ' ' x 8 
+                          . $branch . ': '
+                          . ( $latest_version->{$name}{$branch} || 'unknown' )
+                          . "\n";
                     }
+                    chomp $latest_version_info;
                 }
                 else {
-                    print $latest_version->{$name} || 'unknown', "\n";
+                    $latest_version_info = $latest_version->{$name} || 'unknown';
                 }
+                $self->log->fatal( ' ' x 4,
+                    'latest_version: ' . $latest_version_info );
             }
 
             if ($branches && $name !~ /^cpan-/) {
-                print ' ' x 4 . 'branches: ',
-                  join( ', ', @{ $branches->{$name} } ), "\n";
+                $self->log->fatal( ' ' x 4 . 'branches: ',
+                    join ', ', @{ $branches->{$name} } );
             }
         }
     }
 
     if ( $name && keys %$versions == 0 ) {
-        print $name, " doesn't exist\n";
+        $self->log->fatal( "$name doesn't exist" );
     }
 }
 

Modified: Shipwright/trunk/lib/Shipwright/Script/Maintain.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Script/Maintain.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Script/Maintain.pm	Sun Mar 22 04:31:36 2009
@@ -35,19 +35,20 @@
             map { $_ => $self->$_ }
               qw/skip_requires skip_recommends skip_build_requires/,
         );
-        print "updated order with success\n";
+        $self->log->fatal( 'updated order with success' );
     } 
     if ($self->graph_deps)  {
-        $shipwright->backend->graph_deps(
+        my $out = $shipwright->backend->graph_deps(
             for_dists => [ split /,\s*/, $self->for_dists || '' ],
             map { $_ => $self->$_ }
               qw/skip_requires skip_recommends skip_build_requires/,
         );
+        $self->log->fatal( $out );
     }
 
     if ( $self->update_refs ) {
         $shipwright->backend->update_refs;
-        print "updated refs with success\n";
+        $self->log->fatal( 'updated refs with success' );
     }
 }
 

Modified: Shipwright/trunk/lib/Shipwright/Script/Relocate.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Script/Relocate.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Script/Relocate.pm	Sun Mar 22 04:31:36 2009
@@ -47,7 +47,9 @@
             || $source->{$name} eq $new_source
           )
         {
-            print "the new source is the same as old source, won't update\n";
+            $self->log->fatal(
+                "the new source is the same as old source, won't update"
+            );
         }
         else {
             if ( ref $source->{$name} ) {
@@ -61,11 +63,11 @@
             }
 
             $shipwright->backend->source($source);
-            print "relocated $name to $new_source with success\n";
+            $self->log->fatal( "relocated $name to $new_source with success" );
         }
     }
     else {
-        print "haven't found $name in source.yml, won't relocate\n";
+        $self->log->fatal( "haven't found $name in source.yml, won't relocate" );
     }
 
 }

Modified: Shipwright/trunk/lib/Shipwright/Script/Rename.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Script/Rename.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Script/Rename.pm	Sun Mar 22 04:31:36 2009
@@ -68,7 +68,7 @@
     $shipwright->backend->refs($refs);
     $shipwright->backend->branches($branches) if $branches;
 
-    print "renamed $name to $new_name with success\n";
+    $self->log->fatal( "renamed $name to $new_name with success" );
 }
 
 1;

Modified: Shipwright/trunk/lib/Shipwright/Script/Update.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Script/Update.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Script/Update.pm	Sun Mar 22 04:31:36 2009
@@ -204,7 +204,7 @@
         }
     }
 
-    print "updated with success\n";
+    $self->log->fatal( 'updated with success' );
 }
 
 sub _update {



More information about the Bps-public-commit mailing list