The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

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.38

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->anal(\@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 anal. 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 anal 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 anal 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 enumerated values enum

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_enum($$$$$$)
        use_color($$$)
        use_color_rese($$)
        set_standard($)
        anal($)
        usag($$)
        man($$)
        get_valu($$)
        get_gui($)

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 aegument (checks that the file is valid).

def_newf($$$$$)

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

def_devf($$$$$)

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

def_enum($$$$$$)

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

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.

anal($)

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.

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.

BUGS

None.

AUTHOR

        Name: Mark Veltzer
        Email: mark2776@yahoo.com
        WWW: http://www.geocities.com/mark2776
        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

SEE ALSO

Nothing.

TODO

-add nicer 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.

-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).

-add an option for a parameter type for a file to be written which is not yet on the disk (or is on the disk, or doesnt care...). The options module will check that the file can be created if need be.

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

-make the --license command actually print the GPL.

-make the --copyright command actually print the copyright message.

-if the name is not set by the script then extract it from the script itself.