cvsuser     04/04/17 06:51:08

  Modified:    App-Options/lib/App Options.pm
  Log:
  show_all is off by default if 'option' or 'options' used
  
  Revision  Changes    Path
  1.7       +38 -25    p5ee/App-Options/lib/App/Options.pm
  
  Index: Options.pm
  ===================================================================
  RCS file: /cvs/public/p5ee/App-Options/lib/App/Options.pm,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -w -r1.6 -r1.7
  --- Options.pm        19 Feb 2004 16:17:15 -0000      1.6
  +++ Options.pm        17 Apr 2004 13:51:08 -0000      1.7
  @@ -1,6 +1,6 @@
   
   #############################################################################
  -## $Id: Options.pm,v 1.6 2004/02/19 16:17:15 spadkins Exp $
  +## $Id: Options.pm,v 1.7 2004/04/17 13:51:08 spadkins Exp $
   #############################################################################
   
   package App::Options;
  @@ -10,7 +10,7 @@
   
   use Carp;
   
  -$VERSION = "0.90";
  +$VERSION = "0.91";
   
   =head1 NAME
   
  @@ -74,20 +74,41 @@
   because it integrates the processing of command line options,
   environment variables, and config files.
   
  -It is different from AppConfig (to which its description bears the
  -most resemblance) by its ability to configure a suite of programs
  -with a cascading set of configuration files. This allows for a large
  -number of programs in a large software system to share a small set
  -of configuration files. Some of the option values may be shared, and
  -some may be targetted at a single program or a pattern-matched set
  -of programs.
  -
   Furthermore, its special treatment of the "perlinc"
   option facilitates the inclusion ("use") of application-specific
   perl modules from special places to enable the installation of
   multiple versions of an application on the same system (i.e.
   /usr/myproduct/version).
   
  +The description of the AppConfig distribution sounds similar
  +to is described here.  However, the following are the key
  +differences.
  +
  + * App::Options does its option processing in the BEGIN block.
  +   This allows for the @INC variable to be modified in time
  +   for subsequent "use" and "require" statements.
  +
  + * App::Options "sections" (i.e. "[cleanup]") are conditional.
  +   It is conditional in App::Options, allowing you to use one
  +   set of option files to configure an entire suite of programs
  +   and scripts.  In AppConfig, the section name is simply a 
  +   prefix which gets prepended to subsequest option names.
  +
  + * App::Options consults a cascading set of option files.
  +   These files include those which are system global, project
  +   global, and user private.  This allows for system
  +   administrators, project developers, and in individual
  +   users to all have complementary roles on defining
  +   the configuration values.
  +
  + * App::Options is not a toolkit but a standardized way of
  +   doing option processing.  With AppConfig, you still have
  +   to decide where to put config files, and you still have to
  +   code the "--help" feature.  With App::Options, you simply
  +   "use App::Options;" and all the hard work is done.
  +   Advanced options can be added later as necessary as args
  +   to the "use" statement.
  +
   App::Options is also the easiest command-line processing system
   that I have found anywhere. It then provides a smooth transition to
   more advanced features only as they are needed.  Every single
  @@ -97,12 +118,9 @@
   The documentation of App::Options takes three
   forms below.
   
  -  Reference - describing the API (methods, args)
  -  Flow - describing the order and logic of processing
  -  Tutorial - describing how to use the API in practical situations
  -
  -Hopefully these will be complementary and useful, even if they
  -are somewhat redundant.
  +  API Reference - describing the API (methods, args)
  +  Logic Flow - describing the order and logic of processing
  +  Usage Tutorial - describing how to use the API in practical situations
   
   =head1 RELATION TO THE P5EE PROJECT
   
  @@ -167,7 +185,7 @@
       near as nice to write at the top of your programs.
   
       BEGIN {
  -        use App::Options qw(none);  # import() does not call init()
  +        use App::Options qw(:none); # import() does not call init()
           App::Options->init();       # we call init() manually
       }
   
  @@ -444,7 +462,7 @@
           #################################################################
   
           local(*App::Options::FILE);
  -        my ($option_file, $exclude_section, $app_specified);
  +        my ($option_file, $exclude_section);
           my ($cond, @cond, $exclude);
           while ($#option_file > -1) {
               $option_file = shift(@option_file);
  @@ -459,17 +477,14 @@
                       if (s|^ *\[([^\[\]]*)\] *||) {
                           @cond = split(/;/,$1);   # separate the conditions that 
must be satisfied
                           $exclude = 0;            # assume the condition allows 
inclusion (! $exclude)
  -                        $app_specified = 0;      # the app (program name) itself 
has not yet been specified
                           foreach $cond (@cond) {  # check each condition
                               if ($cond =~ /^([^=]+)=(.*)$/) {  # i.e. [city=ATL] or 
[name=/[Ss]tephen/]
                                   $var = $1;
                                   $value = $2;
  -                                $app_specified = 1 if ($var eq "app");
                               }
                               else {              # i.e. [go] matches the program 
(app) named "go"
                                   $var = "app";
                                   $value = $cond;
  -                                $app_specified = 1;
                               }
                               if ($value =~ m!^/(.*)/$!) {  # variable's value must 
match the regexp
                                   $regexp = $1;
  @@ -481,9 +496,6 @@
                               else {  # a variable's value must match exactly
                                   $exclude = ((defined $values->{$var} ? 
$values->{$var} : "") ne $value);
                               }
  -                            if (!$app_specified && !$exclude) {
  -                                $exclude = ($#cond > -1 && $exclude_section);
  -                            }
                               last if ($exclude);
                           }
                           s/^#.*$//;               # delete comments
  @@ -763,7 +775,8 @@
       printf STDERR "       --%-32s print this message (also -?)\n", "help";
       my (@vars, $show_all, %option_seen);
       $show_all = $init_args->{show_all};
  -    $show_all = 1 if (!defined $show_all);
  +    $show_all = $values->{show_all} if (defined $values->{show_all});
  +    $show_all = 1 if (!defined $show_all && !defined $init_args->{option} && 
!defined $init_args->{options});
       if ($init_args->{options}) {
           @vars = @{$init_args->{options}};
       }
  
  
  

Reply via email to