[libcode-tidyall-perl] 291/374: add --version

Jonas Smedegaard js at alioth.debian.org
Sun Sep 29 22:26:37 UTC 2013


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository libcode-tidyall-perl.

commit 48ed9e05e6d516ff41fe50dd5fafff3b7d1ac957
Author: Jonathan Swartz <swartz at pobox.com>
Date:   Tue Oct 2 12:20:57 2012 -0700

    add --version
---
 Changes                     |    1 +
 bin/tidyall                 |   16 +++++++++++++---
 lib/Code/TidyAll/t/Basic.pm |   10 ++++++++++
 3 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/Changes b/Changes
index f5565c8..1852dc5 100644
--- a/Changes
+++ b/Changes
@@ -6,6 +6,7 @@ Revision history for Code-TidyAll
 
 * Improvements
   - Add -r/--recursive flag to process directories recursively
+  - Add --version
 
 0.13  Sep 30, 2012
 
diff --git a/bin/tidyall b/bin/tidyall
index 2c83de5..1b79a93 100755
--- a/bin/tidyall
+++ b/bin/tidyall
@@ -1,4 +1,5 @@
 #!/usr/bin/perl
+use Config;
 use Cwd qw(cwd realpath);
 use Getopt::Long;
 use Capture::Tiny qw(capture_merged);
@@ -35,16 +36,23 @@ Options:
    --refresh-cache          Erase any existing cache info before processing each file
    --root-dir               Specify root directory explicitly
    --tidyall-class <class>  Subclass to use instead of Code::TidyAll
+   --version                Show version
 ';
 
+sub version {
+    my $version = $Code::TidyAll::VERSION || 'unknown';
+    print "tidyall $version on perl $] built for $Config{archname}\n";
+    exit;
+}
+
 sub usage {
     print $usage;
     exit;
 }
 
 my (
-    %params, $all_files, $conf_file, $conf_name, $git_files,
-    $help,   $inc_dirs,  $list,      $pipe,      $svn_files
+    %params,   $all_files, $conf_file, $conf_name, $git_files, $help,
+    $inc_dirs, $list,      $pipe,      $svn_files, $version
 );
 my @conf_names = Code::TidyAll->default_conf_names;
 
@@ -60,6 +68,7 @@ GetOptions(
     'refresh-cache'   => \$params{refresh_cache},
     'root-dir=s'      => \$params{root_dir},
     'tidyall-class=s' => \$params{tidyall_class},
+    'version'         => \$version,
     'a|all'           => \$all_files,
     'g|git'           => \$git_files,
     'h|help'          => \$help,
@@ -72,7 +81,8 @@ GetOptions(
     'v|verbose'       => \$params{verbose},
     'I'               => \$inc_dirs,
 ) or usage();
-usage() if $help;
+version() if $version;
+usage()   if $help;
 @conf_names = ($conf_name) if defined($conf_name);
 
 unshift( @INC, split( /\s*,\s*/, $inc_dirs ) ) if defined($inc_dirs);
diff --git a/lib/Code/TidyAll/t/Basic.pm b/lib/Code/TidyAll/t/Basic.pm
index 0ec2ba4..55d68b8 100644
--- a/lib/Code/TidyAll/t/Basic.pm
+++ b/lib/Code/TidyAll/t/Basic.pm
@@ -314,6 +314,16 @@ sub test_errors : Tests {
 
 sub test_cli : Tests {
     my $self = shift;
+    my $output;
+
+    $output = capture_stdout {
+        system( "$^X", "bin/tidyall", "--version" );
+    };
+    like( $output, qr/tidyall .* on perl/ );
+    $output = capture_stdout {
+        system( "$^X", "bin/tidyall", "--help" );
+    };
+    like( $output, qr/Usage.*Options:/s );
 
     foreach my $conf_name ( "tidyall.ini", ".tidyallrc" ) {
         my $root_dir  = $self->create_dir();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcode-tidyall-perl.git



More information about the Pkg-perl-cvs-commits mailing list