NAME

Meta::Utils::Opts::Opts - Module to help you analyze command line arguments.

COPYRIGHT

Copyright (C) 2001, 2002 Mark Veltzer; All rights reserved.

LICENSE

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.

DETAILS

MANIFEST: Opts.pm
PROJECT: meta
VERSION: 0.47

SYNOPSIS

package foo;
use Meta::Utils::Opts::Opts qw();
my($obj)=Meta::Utils::Opts::Opts->new();
$obj->set_standard();
$obj->set_free_allo(0);
$obj->analyze(\@ARGV);

DESCRIPTION

This is a library to handle command line arguments for shell scripts. It surrounds the Getopt::Long library and gives a nicer interface. The way to use the library is this: first you have to prepare a list of variables (of different types of course) which will control the behaviour of your software. These values will be overriden by the user if neccessary (or by rc files of the user if neccessary...). 0. call init to initialize the library. 1. call desc to describe what your program does. 2. call auth to describe the author which wrote your program. 3. call (or not call) standard to use standard settings. 4. call a lot of def_{type} routine to define all the arguments to your software (these will include default values). 5. call free/free_mini/free_maxi if you want to allow free arguments to your program or set_free_allo(0) to disallow free arguments to your program. 6. call analyze. If this routine succeds it means that all options given on the command line were valid and all files and directory options were indeed valid files and directories. 7. the values of the different arguements are in the variables you specified as linkage. 8. If you allowed free arguments they are the only thing left in ARGV after the analyze call was made and you can access them from there. 9. If any error was made in the argument passing by the user then the analyze routine will abort with appropriate error and correct usage messages.

* You can call the usage routine of this module whenever you like to print out a usage message.

Currently supported types for parameters are: bool bool integer inte string stri float floa directory dire new directory newd development directory devd file file new file newf development file devf url to be fetched urls enumerated values enum set setx

FUNCTIONS

BEGIN()
new($)
inse($$$$$$$)
def_bool($$$$$)
def_inte($$$$$)
def_stri($$$$$)
def_floa($$$$$)
def_dire($$$$$)
def_newd($$$$$)
def_devd($$$$$)
def_file($$$$$)
def_newf($$$$$)
def_devf($$$$$)
def_urls($$$$$)
def_modu($$$$$)
def_enum($$$$$$)
def_setx($$$$$$)
def_path($$$$$)
def_flst($$$$$)
def_dlst($$$$$)
use_color($$$)
use_color_rese($$)
set_standard($)
analyze($)
usag($$)
pod($$)
man($$)
get_valu($$)
get_gui($)
TEST($)

FUNCTION DOCUMENTATION

BEGIN()

IT will also setup get/set method for the following attributes: name - name of this program. description - description of this program. author - author of this program. license - license under which the program is distributed. copyright - copyright under which the program is distributed. color - use color when printing ? free_allo - allow free arguments on the cmd line ? free_stri - what is the purpose of the free arguments ? free_mini - minimum number of free arguments. free_maxi - maximum number of free arguments. free_noli - set no limit on the number of free arguments ?

new($)

Constructor for this class.

inse($$$$$$$)

Inserts an option string, with a type and a default value.

def_bool($$$$$)

Add a boolean argument to the options.

def_inte($$$$$)

Add an integer argument.

def_stri($$$$$)

Add a string argument.

def_floa($$$$$)

Add a float argument.

def_dire($$$$$)

Add a directory argument (checks that the directory is valid).

def_newd($$$$$)

Add a directory new directory argument (checks that the directory does not exist).

def_devd($$$$$)

Add a development directory argument (checks that the directory exists).

def_file($$$$$)

Add a file argument (checks that the file is valid).

def_newf($$$$$)

Add a new file argument (checks that the file is non-existant).

def_devf($$$$$)

Add a new development file argument (checks that the file is non-existant).

def_urls($$$$$)

Add a new url argument (checks that the file is url and brings the content).

def_modu($$$$$)

Add a new module argument (checks that the file is valid and brings a Meta::Development::Module object).

def_enum($$$$$$)

Add an enumerated argument (checks that the value is out of a set of values).

def_setx($$$$$$)

Add a set argument (checks that the value is a sub set of a set of values).

def_path($$$$$)

Add a path argument (checks that the value is colon separated dir list).

def_flst($$$$$)

Add a file list argument (checks that the value is colon separated file list).

def_dlst($$$$$)

Add a directory list argument (checks that the value is colon separated directory list).

use_color($$$)

This method will print color sequences to the file given if color is used.

use_color_rese($$)

This method will reset color usage on the specified file.

analyze($)

This analyzes the arguments, stores the results and is ready to answer questions about what is going down.

usag($)

This routine prints the programs usage statement to standard error with the program name and all the parameters along with their types and default values. The file on which to print the usage is a parameter.

pod($$)

This method prints the programs parameters in a way suitable for inclusing in a POD OPTION section (with bold parameter names, types etc...). This is for scripts which check that the OPTIONS section in each script is indeed correct.

man($$)

Show the manual page for this program. The file on which the manual is shown is a paramter.

A different path to implementation would be to get the name of the program (not full name but only executable name) and then ask for a man page on that but the problem is that some executables are NOT in the path.

get_valu($$)

This method will retrieve the current value of some option.

set_standard($)

This does the standard initialization for base command line options. Regularly, this is the first routine you should call if you want to do command line parsing the base way. Currently this sets up the help variable correctly.

get_gui($)

This method will show a gui for the options.

TEST($)

Test suite for this module.

SUPER CLASSES

Meta::Ds::Ohash(3)

BUGS

None.

AUTHOR

Name: Mark Veltzer
Email: mailto:veltzer@cpan.org
WWW: http://www.veltzer.org
CPAN id: VELTZER

HISTORY

0.00 MV make Meta::Utils::Opts object oriented
0.01 MV more harsh checks on perl code
0.02 MV fix todo items look in pod documentation
0.03 MV add enumerated types to options
0.04 MV more on tests/more checks to perl
0.05 MV change new methods to have prototypes
0.06 MV UI for Opts.pm
0.07 MV fix up perl cooking a lot
0.08 MV correct die usage
0.09 MV fix expect.pl test
0.10 MV more organization
0.11 MV perl code quality
0.12 MV more perl quality
0.13 MV more perl quality
0.14 MV make all papers papers
0.15 MV perl documentation
0.16 MV more perl quality
0.17 MV perl qulity code
0.18 MV more perl code quality
0.19 MV more perl quality
0.20 MV revision change
0.21 MV better general cook schemes
0.22 MV languages.pl test online
0.23 MV xml/rpc client/server
0.24 MV html site update
0.25 MV perl packaging
0.26 MV PDMT
0.27 MV license issues
0.28 MV pictures database
0.29 MV tree type organization in databases
0.30 MV more movies
0.31 MV md5 project
0.32 MV database
0.33 MV perl module versions in files
0.34 MV movies and small fixes
0.35 MV graph visualization
0.36 MV thumbnail user interface
0.37 MV dbman package creation
0.38 MV more thumbnail issues
0.39 MV website construction
0.40 MV improve the movie db xml
0.41 MV web site development
0.42 MV web site automation
0.43 MV SEE ALSO section fix
0.44 MV put all tests in modules
0.45 MV move tests to modules
0.46 MV download scripts
0.47 MV web site development

SEE ALSO

Getopt::Long(3), Gtk(3), Meta::Class::MethodMaker(3), Meta::Ds::Ohash(3), Meta::Lang::Perl::Perl(3), Meta::Utils::Color(3), Meta::Utils::List(3), Meta::Utils::Opts::Sopt(3), Meta::Utils::Output(3), Meta::Utils::Progname(3), Meta::Utils::System(3), strict(3)

TODO

-add long type description for each option type.

-Add some more features: 0. must parameters - paramters which must be there. 1. integer parameters which are limited in range. 3. a parameter which is a regular expression (and test the regular expression) 4. parameters which are allowed a selection out of a set.

-add list parameters and hash parameters

-The help is not handled well if there is a limit on the minimal number of free arguments (if the user just asks --help that check fails and the usage is printed with an error but actually this is not an error...)

-do it so if I have a fixed sized list of free args I could also attach them to variables (this way I dont have to have lines like one,two,three=ARGV0,ARGV1,ARGV2 in my scripts....(maybe even a more general approach of fixed sized coming first and then var sized ?)

-in the usage print that option passing is in the GNU stype. Maybe even offer an option to show help on passing GNU args... add a document and help on how to set user defined defaults (if you implement that mechanism).

-fix the man command which does not use the file argument given to it.