|
NAMEAppConfig::Std - subclass of AppConfig that provides standard optionsSYNOPSISuse 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 DESCRIPTIONAppConfig::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:
Please read the copious documentation for AppConfig to find out what else you can do with this module. STANDARD OPTIONSThe module adds five standard configuration variables and command-line switches. You can define additional variables as you would with AppConfig.HELPThe -help switch will result in a short help message. This is generated using Pod::Usage, which displays the OPTIONS section of your pod. The script will exit with an exit value of 0.DOCThe -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.VERSIONThe -version switch will display the version of the invoking script. This assumes that you have defined $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. DEBUGThe -debug switch just sets the debug variable. This is useful for displaying information in debug mode:$foobar->dump() if $config->debug; VERBOSEThe -verbose switch just sets the verbose variable. This is useful for displaying verbose information as a script runs:print STDERR "Running foobar\n" if $config->verbose; TODOPlease let me know if you have ideas for additional switches, or other modifications. Things currently being mulled:
EXAMPLEThe 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 "pod2man" for more details. SEE ALSOAppConfig - 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.Pod::Usage - Brad Appleton's module for extracting usage information out of a file's pod. This is used for the -doc and -help switches. Available from CPAN as part of the PodParser distribution. perlpod <https://metacpan.org/pod/distribution/perl/pod/perlpod.pod> - documentation from the perl distribution that describes the pod format. pod2man <https://metacpan.org/pod/distribution/podlators/scripts/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. REPOSITORY<https://github.com/neilb/AppConfig-Std>AUTHORNeil Bowers <neil@bowers.com>COPYRIGHTCopyright (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.
Visit the GSP FreeBSD Man Page Interface. |