[libappconfig-std-perl] 01/03: Import original source of AppConfig-Std 1.09

Lucas Kanashiro kanashiro-guest at moszumanska.debian.org
Sun Jul 19 16:57:00 UTC 2015


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

kanashiro-guest pushed a commit to branch master
in repository libappconfig-std-perl.

commit 63bc66f72d0324823d72b42d2cfdd6d27742474a
Author: Lucas Kanashiro <kanashiro.duarte at gmail.com>
Date:   Sun Jul 19 12:40:43 2015 -0300

    Import original source of AppConfig-Std 1.09
---
 Changes              |  60 ++++++++
 MANIFEST             |  11 ++
 META.json            |  48 +++++++
 META.yml             |  26 ++++
 Makefile.PL          |  41 ++++++
 README               |  28 ++++
 lib/AppConfig/Std.pm | 381 +++++++++++++++++++++++++++++++++++++++++++++++++++
 t/basic.t            | 141 +++++++++++++++++++
 t/getopt.t           | 141 +++++++++++++++++++
 t/getscript.pl       |  87 ++++++++++++
 t/testscript.pl      |  87 ++++++++++++
 11 files changed, 1051 insertions(+)

diff --git a/Changes b/Changes
new file mode 100644
index 0000000..0a3c7db
--- /dev/null
+++ b/Changes
@@ -0,0 +1,60 @@
+Revision history for perl module AppConfig::Std
+
+1.09 2014-01-30
+
+    - Added "use warnings"
+    - min Perl version 5.6.0
+
+1.08 2013-07-20
+
+    - ChangeLog renamed to Changes and reformatted as per CPAN::Changes::Spec
+    - Added repository details to metadata (Makefile.PL) and pod
+    - Added license type to metadata (in Makefile.PL)
+
+1.07 2002-07-03
+
+    - We now over-ride the getopt() method, and handle the
+      standard options if getopt() is used rather than args().
+      Change based on a patch from Martin Bloecker.
+    - Added a set of tests which exercise the getopt() method.
+    - Renamed the show_version() function to _show_version(),
+      to signify its private status.
+
+
+1.06 2002-03-09
+
+    - The testsuite was try to invoke perl on the test script,
+      which fails if you install the binary as something other
+      than "perl". Changed "perl" to "$^X". Also invoked perl
+      with -Iblib/lib when running the test, so that it actually
+      pulls in the version you think you're testing :-)
+      Thanks to Ed Santiago for both of these.
+
+
+1.05 2002-01-19
+
+    - Added a basic test-suite. Tests all switches apart
+      from -help. The test-suite works by comparing the
+      output of a test script with expected output.
+      The output of -help will be formatted slightly
+      differently on different systems (pod2usage() uses
+      perldoc to format the output), so the comparison
+      is likely to fail.
+
+
+1.04 2002-01-15
+
+    - Updated call to pod2usage() - the API has changed.
+    - Minor improvements to documentation.
+
+
+1.03 2001-02-26
+
+    - Tied up the documentation; eg updated references to CPAN.
+    - Added a -verbose switch - found I was adding one of these
+      to just about all of my scripts.
+
+1.02 1998-12-09
+
+    - First version of module. Created from previous module App::StdConfig.
+
diff --git a/MANIFEST b/MANIFEST
new file mode 100644
index 0000000..1298129
--- /dev/null
+++ b/MANIFEST
@@ -0,0 +1,11 @@
+lib/AppConfig/Std.pm
+Makefile.PL
+README
+MANIFEST
+Changes
+t/basic.t
+t/testscript.pl
+t/getopt.t
+t/getscript.pl
+META.yml                                 Module YAML meta-data (added by MakeMaker)
+META.json                                Module JSON meta-data (added by MakeMaker)
diff --git a/META.json b/META.json
new file mode 100644
index 0000000..49d12ad
--- /dev/null
+++ b/META.json
@@ -0,0 +1,48 @@
+{
+   "abstract" : "unknown",
+   "author" : [
+      "Neil Bowers <neil at bowers.com>"
+   ],
+   "dynamic_config" : 1,
+   "generated_by" : "ExtUtils::MakeMaker version 6.86, CPAN::Meta::Converter version 2.133380",
+   "license" : [
+      "perl_5"
+   ],
+   "meta-spec" : {
+      "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
+      "version" : "2"
+   },
+   "name" : "AppConfig-Std",
+   "no_index" : {
+      "directory" : [
+         "t",
+         "inc"
+      ]
+   },
+   "prereqs" : {
+      "build" : {
+         "requires" : {
+            "ExtUtils::MakeMaker" : "0"
+         }
+      },
+      "configure" : {
+         "requires" : {
+            "ExtUtils::MakeMaker" : "0"
+         }
+      },
+      "runtime" : {
+         "requires" : {
+            "AppConfig" : "1.52",
+            "Pod::Usage" : "1.14",
+            "perl" : "5.006"
+         }
+      }
+   },
+   "release_status" : "stable",
+   "resources" : {
+      "repository" : {
+         "url" : "https://github.com/neilbowers/AppConfig-Std"
+      }
+   },
+   "version" : "1.09"
+}
diff --git a/META.yml b/META.yml
new file mode 100644
index 0000000..367401f
--- /dev/null
+++ b/META.yml
@@ -0,0 +1,26 @@
+---
+abstract: unknown
+author:
+  - 'Neil Bowers <neil at bowers.com>'
+build_requires:
+  ExtUtils::MakeMaker: 0
+configure_requires:
+  ExtUtils::MakeMaker: 0
+dynamic_config: 1
+generated_by: 'ExtUtils::MakeMaker version 6.86, CPAN::Meta::Converter version 2.133380'
+license: perl
+meta-spec:
+  url: http://module-build.sourceforge.net/META-spec-v1.4.html
+  version: 1.4
+name: AppConfig-Std
+no_index:
+  directory:
+    - t
+    - inc
+requires:
+  AppConfig: 1.52
+  Pod::Usage: 1.14
+  perl: 5.006
+resources:
+  repository: https://github.com/neilbowers/AppConfig-Std
+version: 1.09
diff --git a/Makefile.PL b/Makefile.PL
new file mode 100644
index 0000000..f236bc0
--- /dev/null
+++ b/Makefile.PL
@@ -0,0 +1,41 @@
+#
+# Makefile.PL for AppConfig::Std
+#
+# Filename:     Makefile.PL
+# Author:       Neil Bowers
+# Created:      9 December 1998
+#
+
+use ExtUtils::MakeMaker;
+
+my $mm_ver = $ExtUtils::MakeMaker::VERSION;
+if ($mm_ver =~ /_/) { # dev version
+    $mm_ver = eval $mm_ver;
+    die $@ if $@;
+}
+
+&WriteMakefile(
+    NAME		 => 'AppConfig::Std',
+    DISTNAME	 => 'AppConfig-Std',
+    VERSION_FROM => 'lib/AppConfig/Std.pm',
+    PREREQ_PM	 => {
+        'AppConfig'   => 1.52,
+        'Pod::Usage'  => 1.14,
+    },
+    AUTHOR		=> 'Neil Bowers <neil at bowers.com>',
+    dist		=> {COMPRESS => 'gzip', SUFFIX => 'gz'},
+
+    META_MERGE => {
+        resources => {
+            repository => 'https://github.com/neilbowers/AppConfig-Std',
+        },
+    },
+    LICENSE      => 'perl',
+
+    ($mm_ver >= 6.48
+        ? (MIN_PERL_VERSION => 5.006)
+        : ()
+    ),
+
+);
+
diff --git a/README b/README
new file mode 100644
index 0000000..d94ff21
--- /dev/null
+++ b/README
@@ -0,0 +1,28 @@
+
+			AppConfig::Std
+
+AppConfig::Std is a subclass of Andy Wardley's AppConfig module,
+to provide standard command-line arguments for tool scripts.
+
+AppConfig is a Perl5 module to handle global configuration variables
+for perl programs. AppConfig::Std provides the following switches:
+
+	-help           display a short help statement
+	-doc            display the full documentation (formatted pod)
+	-version        display the version of the script
+	-verbose	turn on verbose status/progress output
+	-debug          turn on debugging output
+
+The module is a subclass of AppConfig, and uses Brad Appleton's
+Pod::Usage module to implement the -help and -doc switches.
+
+To install this module, you should just have to run the following:
+
+	% perl Makefile.PL
+	% make
+	% make test
+	% make install
+
+I'd be happy to hear of any suggestions for improving this module.
+
+Neil Bowers <neil at bowers.com>
diff --git a/lib/AppConfig/Std.pm b/lib/AppConfig/Std.pm
new file mode 100644
index 0000000..7fb0eab
--- /dev/null
+++ b/lib/AppConfig/Std.pm
@@ -0,0 +1,381 @@
+#=======================================================================
+#
+# AppConfig::Std - subclass of AppConfig to provide standard tool config
+#
+# This is a perl module which implements a specialisation of
+# Andy Wardley's AppConfig module. It basically provides five standard
+# command-line arguments:
+#
+#	-help		display a short help statement
+#	-doc		display the full documentation (formatted pod)
+#	-version	display the version of the script
+#	-verbose	turn on verbose output
+#	-debug		turn on debugging output
+#
+# The -help and -doc functionality is provided by Brad Appleton's
+# Pod::Usage module. I wrote this module because I was cutting &
+# pasting code between scripts.
+#
+# Written by Neil Bowers <neil at bowers.com>
+#
+# Copyright (C) 2002-2013 Neil Bowers.
+# Copyright (C) 1998-2001 Canon Research Centre Europe Ltd.
+# All Rights Reserved.
+#
+#=======================================================================
+
+package AppConfig::Std;
+use 5.006;
+use strict;
+use warnings;
+
+use AppConfig;
+# we also make use of Pod::Usage, but require it if needed
+
+use vars qw(@ISA $VERSION);
+
+$VERSION = '1.09';
+ at ISA     = qw(AppConfig);
+
+#=======================================================================
+#
+# new() - constructor
+#
+# The constructor:
+#	> invokes the AppConfig constructor with standard config
+#	> blesses the instance into this package
+#	> defines the -help, -doc, -version, and -debug options
+#       > configures with any additional options passed to constructor
+#
+#=======================================================================
+sub new
+{
+    my $class = shift;
+    my $cfg   = shift;
+
+    my $self;
+
+
+    $self = bless AppConfig->new({
+                               GLOBAL => { ARGCOUNT => 1
+                                         }}), $class;
+
+    $self->define('help',    { ARGCOUNT => 0 } );
+    $self->define('doc',     { ARGCOUNT => 0 } );
+    $self->define('version', { ARGCOUNT => 0 } );
+    $self->define('verbose', { ARGCOUNT => 0 } );
+    $self->define('debug',   { ARGCOUNT => 0 } );
+
+    $self->_configure($cfg) if defined $cfg;
+
+    return $self;
+}
+
+
+#=======================================================================
+#
+# args() - parse command-line arguments (@ARGV)
+#
+# We over-ride the args() method, to handle the -doc, -help
+# and -version command-line switches.
+#
+#=======================================================================
+sub args
+{
+    my $self = shift;
+    my $ref  = shift;
+
+    my $result;
+
+
+    #-------------------------------------------------------------------
+    # Use AppConfig's args() method to parse the command-line.
+    #-------------------------------------------------------------------
+    $result = $self->SUPER::args($ref);
+
+    #-------------------------------------------------------------------
+    # If the command-line was successfully parsed (returned TRUE),
+    # then check for the standard command-line switches.
+    #-------------------------------------------------------------------
+    if ($result)
+    {
+	$self->_handle_std_opts();
+    }
+
+    return $result;
+}
+
+
+#=======================================================================
+#
+# getopt() - parse command-line arguments (@ARGV)
+#
+# We over-ride the getopt() method, to handle the -doc, -help
+# and -version command-line switches.
+#
+#=======================================================================
+sub getopt
+{
+    my $self = shift;
+    my $ref  = shift;
+
+    my $result;
+
+
+    #-------------------------------------------------------------------
+    # Use AppConfig's getopt() method to parse the command-line.
+    #-------------------------------------------------------------------
+    $result = $self->SUPER::getopt($ref);
+
+    #-------------------------------------------------------------------
+    # If the command-line was successfully parsed (returned TRUE),
+    # then check for the standard command-line switches.
+    #-------------------------------------------------------------------
+    if ($result)
+    {
+	$self->_handle_std_opts();
+    }
+
+    return $result;
+}
+
+
+#=======================================================================
+#
+# _handle_std_opts() - handle the standard options defined by us
+#
+#=======================================================================
+sub _handle_std_opts
+{
+    my $self = shift;
+
+
+    #-------------------------------------------------------------------
+    # We only load Pod::Usage if we're gonna use it.
+    # Because we're require'ing, the functions don't get exported
+    # to us, hence the explicit namespace reference.
+    #-------------------------------------------------------------------
+    require Pod::Usage if $self->doc || $self->help;
+    Pod::Usage::pod2usage({-verbose => 2, -exitval => 0}) if $self->doc();
+    Pod::Usage::pod2usage({-verbose => 1, -exitval => 0}) if $self->help();
+    _show_version() if $self->version();
+}
+
+
+#=======================================================================
+#
+# _show_version()
+#
+# Display the version number of the script. This assumes that
+# the invoking script has defined $VERSION.
+#
+#=======================================================================
+sub _show_version
+{
+    print "$main::VERSION\n";
+    exit 0;
+}
+
+
+1;
+
+__END__
+
+=head1 NAME
+
+AppConfig::Std - subclass of AppConfig that provides standard options
+
+=head1 SYNOPSIS
+
+    use AppConfig::Std;
+    
+    $config = AppConfig::Std->new();
+    
+    # all AppConfig methods supported
+    $config->define('foo');            # define variable foo
+    $config->set('foo', 25);           # setting a variable
+    $val = $config->get('foo');        # getting variable
+    $val = $config->foo();             # shorthand for getting
+    
+    $config->args(\@ARGV);             # parse command-line
+    $config->file(".myconfigrc")       # read config file
+
+=head1 DESCRIPTION
+
+B<AppConfig::Std> is a Perl module that provides a set of
+standard configuration variables and command-line switches.
+It is implemented as a subclass of AppConfig; AppConfig provides
+a general mechanism for handling global configuration variables.
+
+The features provided by AppConfig::Std are:
+
+=over 4
+
+=item *
+
+Standard command-line arguments: -help, -doc, -version,
+-verbose, and -debug. AppConfig::Std handles the -help, -doc,
+and -version switches for you, so you don't need to duplicate
+that code in all of your scripts.
+These are described below.
+
+=item *
+
+The ARGCOUNT default is set to 1. This means that by default
+all switches are expected to take a value. To change this,
+set the ARGCOUNT parameter when defining the variable:
+
+    $config->define('verbose', { ARGCOUNT => 0 } );
+
+=back
+
+Please read the copious documentation for AppConfig to
+find out what else you can do with this module.
+
+=head1 STANDARD OPTIONS
+
+The module adds five standard configuration variables
+and command-line switches. You can define additional
+variables as you would with AppConfig.
+
+=head2 HELP
+
+The B<-help> switch will result in a short help message.
+This is generated using Pod::Usage, which displays the B<OPTIONS>
+section of your pod. The script will exit with an exit value of 0.
+
+=head2 DOC
+
+The B<-doc> switch will result in the entire documentation
+being formatted to the screen.
+This is also done with Pod::Usage.
+The script will exit with an exit value of 0.
+
+=head2 VERSION
+
+The B<-version> switch will display the version of the invoking script.
+This assumes that you have defined C<$VERSION> in your script
+with something like the following:
+
+    use vars qw( $VERSION );
+    $VERSION = sprintf("%d.%02d", q$Revision: 1.7 $ =~ /(\d+)\.(\d+)/);
+
+The script will exit with an exit value of 0.
+
+=head2 DEBUG
+
+The B<-debug> switch just sets the B<debug> variable.
+This is useful for displaying information in debug mode:
+
+    $foobar->dump() if $config->debug;
+
+=head2 VERBOSE
+
+The B<-verbose> switch just sets the B<verbose> variable.
+This is useful for displaying verbose information as
+a script runs:
+
+    print STDERR "Running foobar\n" if $config->verbose;
+
+=head1 TODO
+
+Please let me know if you have ideas for additional switches,
+or other modifications. Things currently being mulled:
+
+=over 4
+
+=item *
+
+Support brief switches, such as B<-h> as well as B<-help>.
+This could be a config option for the constructor.
+
+=item *
+
+Include a sample script called B<mkscript>, which would create
+a template script along with Makefile.PL, MANIFEST, etc.
+Kinda of a h2xs for scripts.
+
+=back
+
+=head1 EXAMPLE
+
+The following is the outline of a simple script that illustrates
+use of the AppConfig::Std module:
+
+    #!/usr/bin/perl -w
+    use strict;
+    use AppConfig::Std;
+    
+    use vars qw( $VERSION );
+    $VERSION = '1.0';
+    
+    my $config = AppConfig::Std->new();
+    
+    # parse command-line and handle std switches
+    $config->args(\@ARGV);
+    
+    exit 0;
+    
+    __END__
+    
+    =head1 NAME
+    
+    standard pod format documentation
+
+The pod documentation is expected to have the NAME, SYNOPSIS,
+DESCRIPTION, and OPTIONS sections. See the documentation
+for C<pod2man> for more details.
+
+=head1 SEE ALSO
+
+=over 4
+
+=item AppConfig
+
+Andy Wardley's module for unifying command-line switches and
+cofiguration files into the notion of configuration variables.
+AppConfig::Std requires version 1.52+ of the module,
+which is available from CPAN:
+
+    http://www.cpan.org/modules/by-module/AppConfig/
+
+=item Pod::Usage
+
+Brad Appleton's module for extracting usage information out
+of a file's pod. This is used for the B<-doc> and B<-help> switches.
+Available from CPAN as part of the PodParser distribution:
+
+    http://www.cpan.org/modules/by-module/Pod/
+
+=item perlpod
+
+Documentation from the perl distribution that describes
+the pod format.
+
+=item pod2man
+
+Particularly the NOTES section in the documentation
+which describes the sections you should include in your documentation.
+AppConfig::Std uses Pod::Usage, which assumes well-formed pod.
+
+=back
+
+=head1 REPOSITORY
+
+L<https://github.com/neilbowers/AppConfig-Std>
+
+=head1 AUTHOR
+
+Neil Bowers E<lt>neil at bowers.comE<gt>
+
+=head1 COPYRIGHT
+
+Copyright (c) 2002-2013 Neil Bowers.
+
+Copyright (c) 1998-2001 Canon Research Centre Europe. All rights reserved.
+
+This script is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
diff --git a/t/basic.t b/t/basic.t
new file mode 100755
index 0000000..9462cc1
--- /dev/null
+++ b/t/basic.t
@@ -0,0 +1,141 @@
+#!./perl
+#
+# basic.t - basic tests for AppConfig::Std
+#
+# the tests all use testscript.pl
+#
+
+my @expected;
+my $e = '';
+my $args = '';
+my $output;
+
+while (<DATA>)
+{
+    if (/^ARGS:(.*)$/)
+    {
+	$args = $1;
+    }
+    elsif (/^####$/)
+    {
+	push(@expected, [$args, $e]);
+	$args = '';
+	$e = '';
+    }
+    else
+    {
+	$e .= $_;
+    }
+}
+
+print "1..", int(@expected), "\n";
+
+
+for ($i = 1; $i <= int(@expected); ++$i)
+{
+    $args = $expected[$i-1]->[0];
+    $output = `$^X -Iblib/lib t/testscript.pl $args 2>&1`;
+    if ($output eq $expected[$i-1]->[1]) {
+	print "ok $i\n";
+    } else {
+print STDERR "OUTPUT:\n$output\nEXPECTED:\n", $expected[$i-1]->[1], "\n";
+	print "not ok $i\n";
+    }
+}
+
+exit 0;
+
+__DATA__
+ARGS:
+Start of testscript.pl [AppConfig::Std 1.09]
+End of testscript.pl
+####
+ARGS: -version
+Start of testscript.pl [AppConfig::Std 1.09]
+1.0
+####
+ARGS: -verbose
+Start of testscript.pl [AppConfig::Std 1.09]
+Verbose output enabled
+End of testscript.pl
+####
+ARGS: -debug
+Start of testscript.pl [AppConfig::Std 1.09]
+Debug output enabled
+End of testscript.pl
+####
+ARGS: -verbose -debug
+Start of testscript.pl [AppConfig::Std 1.09]
+Verbose output enabled
+Debug output enabled
+End of testscript.pl
+####
+ARGS: -foobar
+Start of testscript.pl [AppConfig::Std 1.09]
+Foobar flag ON
+End of testscript.pl
+####
+ARGS: -foobar -verbose -debug
+Start of testscript.pl [AppConfig::Std 1.09]
+Verbose output enabled
+Debug output enabled
+Foobar flag ON
+End of testscript.pl
+####
+ARGS: -color red
+Start of testscript.pl [AppConfig::Std 1.09]
+A color of red was given
+End of testscript.pl
+####
+ARGS: -color
+Start of testscript.pl [AppConfig::Std 1.09]
+-color expects an argument
+End of testscript.pl
+####
+ARGS: -color blue -foobar -verbose -debug
+Start of testscript.pl [AppConfig::Std 1.09]
+Verbose output enabled
+Debug output enabled
+Foobar flag ON
+A color of blue was given
+End of testscript.pl
+####
+ARGS: -country
+Start of testscript.pl [AppConfig::Std 1.09]
+-country expects an argument
+End of testscript.pl
+####
+ARGS: -country Sweden
+Start of testscript.pl [AppConfig::Std 1.09]
+The country was set to Sweden.
+End of testscript.pl
+####
+ARGS: -help
+Start of testscript.pl [AppConfig::Std 1.09]
+Usage:
+      testscript.pl [ -version | -debug | -verbose | -doc | -help ]
+                    [ -color C | -country C | -foobar ]
+
+Options:
+    -color C
+        Provide a color.
+
+    -country C
+        Specify a country.
+
+    -foobar
+        Turn on the foobar flag.
+
+    -doc
+        Display the full documentation for testscript.pl.
+
+    -verbose or -v
+        Display verbose information as testscript.pl runs.
+
+    -version
+        Display the version of testscript.pl.
+
+    -debug
+        Display debugging information as testscript.pl runs.
+
+####
diff --git a/t/getopt.t b/t/getopt.t
new file mode 100755
index 0000000..9102543
--- /dev/null
+++ b/t/getopt.t
@@ -0,0 +1,141 @@
+#!./perl
+#
+# basic.t - tests for getopt() method of AppConfig::Std
+#
+# the tests all use getscript.pl
+#
+
+my @expected;
+my $e = '';
+my $args = '';
+my $output;
+
+while (<DATA>)
+{
+    if (/^ARGS:(.*)$/)
+    {
+	$args = $1;
+    }
+    elsif (/^####$/)
+    {
+	push(@expected, [$args, $e]);
+	$args = '';
+	$e = '';
+    }
+    else
+    {
+	$e .= $_;
+    }
+}
+
+print "1..", int(@expected), "\n";
+
+
+for ($i = 1; $i <= int(@expected); ++$i)
+{
+    $args = $expected[$i-1]->[0];
+    $output = `$^X -Iblib/lib t/getscript.pl $args 2>&1`;
+    if ($output eq $expected[$i-1]->[1]) {
+	print "ok $i\n";
+    } else {
+print STDERR "OUTPUT:\n$output\nEXPECTED:\n", $expected[$i-1]->[1], "\n";
+	print "not ok $i\n";
+    }
+}
+
+exit 0;
+
+__DATA__
+ARGS:
+Start of getscript.pl [AppConfig::Std 1.09]
+End of getscript.pl
+####
+ARGS: -version
+Start of getscript.pl [AppConfig::Std 1.09]
+1.0
+####
+ARGS: -verbose
+Start of getscript.pl [AppConfig::Std 1.09]
+Verbose output enabled
+End of getscript.pl
+####
+ARGS: -debug
+Start of getscript.pl [AppConfig::Std 1.09]
+Debug output enabled
+End of getscript.pl
+####
+ARGS: -verbose -debug
+Start of getscript.pl [AppConfig::Std 1.09]
+Verbose output enabled
+Debug output enabled
+End of getscript.pl
+####
+ARGS: -foobar
+Start of getscript.pl [AppConfig::Std 1.09]
+Foobar flag ON
+End of getscript.pl
+####
+ARGS: -foobar -verbose -debug
+Start of getscript.pl [AppConfig::Std 1.09]
+Verbose output enabled
+Debug output enabled
+Foobar flag ON
+End of getscript.pl
+####
+ARGS: -color red
+Start of getscript.pl [AppConfig::Std 1.09]
+A color of red was given
+End of getscript.pl
+####
+ARGS: -color
+Start of getscript.pl [AppConfig::Std 1.09]
+Option color requires an argument
+End of getscript.pl
+####
+ARGS: -color blue -foobar -verbose -debug
+Start of getscript.pl [AppConfig::Std 1.09]
+Verbose output enabled
+Debug output enabled
+Foobar flag ON
+A color of blue was given
+End of getscript.pl
+####
+ARGS: -country
+Start of getscript.pl [AppConfig::Std 1.09]
+Option country requires an argument
+End of getscript.pl
+####
+ARGS: -country Sweden
+Start of getscript.pl [AppConfig::Std 1.09]
+The country was set to Sweden.
+End of getscript.pl
+####
+ARGS: -help
+Start of getscript.pl [AppConfig::Std 1.09]
+Usage:
+      getscript.pl [ -version | -debug | -verbose | -doc | -help ]
+                    [ -color C | -country C | -foobar ]
+
+Options:
+    -color C
+        Provide a color.
+
+    -country C
+        Specify a country.
+
+    -foobar
+        Turn on the foobar flag.
+
+    -doc
+        Display the full documentation for getscript.pl.
+
+    -verbose or -v
+        Display verbose information as getscript.pl runs.
+
+    -version
+        Display the version of getscript.pl.
+
+    -debug
+        Display debugging information as getscript.pl runs.
+
+####
diff --git a/t/getscript.pl b/t/getscript.pl
new file mode 100755
index 0000000..dc944d8
--- /dev/null
+++ b/t/getscript.pl
@@ -0,0 +1,87 @@
+#!./perl
+
+use AppConfig::Std;
+use vars qw ($VERSION);
+
+$VERSION = '1.0';
+$| = 1;
+
+print "Start of getscript.pl [AppConfig::Std $AppConfig::Std::VERSION]\n";
+
+my $config = AppConfig::Std->new();
+
+$config->define('foobar', { ARGCOUNT => 0 });
+$config->define('color',  { ARGCOUNT => 1 });
+$config->define('country',); # don't give ARGCOUNT - defaults to 1
+
+$config->getopt(\@ARGV);
+
+print "Verbose output enabled\n" if $config->verbose;
+print "Debug output enabled\n" if $config->debug;
+print "Foobar flag ON\n" if $config->foobar;
+print "A color of ", $config->color, " was given\n" if $config->color;
+print "The country was set to ", $config->country, ".\n" if $config->country;
+
+print "End of getscript.pl\n";
+
+exit 0;
+
+__END__
+
+=head1 NAME
+
+getscript.pl - test script for AppConfig::Std test-suite
+
+=head1 SYNOPSIS
+
+  getscript.pl [ -version | -debug | -verbose | -doc | -help ]
+                [ -color C | -country C | -foobar ]
+
+=head1 DESCRIPTION
+
+getscript.pl is a simple perl script for testing AppConfig::Std.
+
+=head1 OPTIONS
+
+=over 4
+
+=item B<-color C>
+
+Provide a color.
+
+=item B<-country C>
+
+Specify a country.
+
+=item B<-foobar>
+
+Turn on the foobar flag.
+
+=item B<-doc>
+
+Display the full documentation for getscript.pl.
+
+=item B<-verbose> or B<-v>
+
+Display verbose information as getscript.pl runs.
+
+=item B<-version>
+
+Display the version of getscript.pl.
+
+=item B<-debug>
+
+Display debugging information as getscript.pl runs.
+
+=back
+
+=head1 VERSION
+
+This doc describes getscript.pl 1.0.
+
+=head1 AUTHOR
+
+Neil Bowers <neil at bowers.com>
+
+=cut
+
diff --git a/t/testscript.pl b/t/testscript.pl
new file mode 100755
index 0000000..6e12a53
--- /dev/null
+++ b/t/testscript.pl
@@ -0,0 +1,87 @@
+#!./perl
+
+use AppConfig::Std;
+use vars qw ($VERSION);
+
+$VERSION = '1.0';
+$| = 1;
+
+print "Start of testscript.pl [AppConfig::Std $AppConfig::Std::VERSION]\n";
+
+my $config = AppConfig::Std->new();
+
+$config->define('foobar', { ARGCOUNT => 0 });
+$config->define('color',  { ARGCOUNT => 1 });
+$config->define('country',); # don't give ARGCOUNT - defaults to 1
+
+$config->args(\@ARGV);
+
+print "Verbose output enabled\n" if $config->verbose;
+print "Debug output enabled\n" if $config->debug;
+print "Foobar flag ON\n" if $config->foobar;
+print "A color of ", $config->color, " was given\n" if $config->color;
+print "The country was set to ", $config->country, ".\n" if $config->country;
+
+print "End of testscript.pl\n";
+
+exit 0;
+
+__END__
+
+=head1 NAME
+
+testscript.pl - test script for AppConfig::Std test-suite
+
+=head1 SYNOPSIS
+
+  testscript.pl [ -version | -debug | -verbose | -doc | -help ]
+                [ -color C | -country C | -foobar ]
+
+=head1 DESCRIPTION
+
+testscript.pl is a simple perl script for testing AppConfig::Std.
+
+=head1 OPTIONS
+
+=over 4
+
+=item B<-color C>
+
+Provide a color.
+
+=item B<-country C>
+
+Specify a country.
+
+=item B<-foobar>
+
+Turn on the foobar flag.
+
+=item B<-doc>
+
+Display the full documentation for testscript.pl.
+
+=item B<-verbose> or B<-v>
+
+Display verbose information as testscript.pl runs.
+
+=item B<-version>
+
+Display the version of testscript.pl.
+
+=item B<-debug>
+
+Display debugging information as testscript.pl runs.
+
+=back
+
+=head1 VERSION
+
+This doc describes testscript.pl 1.0.
+
+=head1 AUTHOR
+
+Neil Bowers <neil at bowers.com>
+
+=cut
+

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



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