any additional docs for newgetopt.pl? 
Author Message
 any additional docs for newgetopt.pl?

I just discovered (by accident) newgetopt.pl! As I recall it is not
comvered in the Camel book. Is it covered in the Llama book? It's not
mentioned in the manpage.

It looks like something I'd really like to use, but it's a bit steep
for me, a newbie in perl, to try and figure it out from the source,
especially if there's some good docs out there somewhere.

From newgetopt.pl:

# This package implements a new getopt function. This function adheres
# to the new syntax (long option names, no bundling).

Is there some documentation for this "new syntax"?

Thanks!

--

 (301) 286-2396                          fax: (301) 286-1754



Fri, 17 May 1996 03:37:15 GMT  
 any additional docs for newgetopt.pl?

Quote:

>From newgetopt.pl:
># This package implements a new getopt function. This function adheres
># to the new syntax (long option names, no bundling).
>Is there some documentation for this "new syntax"?

The "new syntax" is dereived from the POSIX and GNU specifications.
Both specifications are still subject to modifications.

The syntax that newgetopt uses is much simpler:

   1. options that can be set:

        --option

      this causes variable $opt_option to be defined and set to 1.

   2. options that take a value:

        --voption value

      this causes $opt_voption to be set to the value.

   3. options that take an optional value:

        --ovoption

      (if not followed by a value): this causes $opt_ovoption to be
      defined and set to "".

For convenience (but not conforming the POSIX specs!) you can use a
single hyphen instead of the double hyphen.

In your perl program, you just call

      &newgetopt ("option", "voption=s", "ovoption:s")

(use i (integer) or f (float) instead of s (string) if you want a
numeric option value only).

Normally multiple occurrences of options will overwrite, but if you
specify



values.

Finally, the result of &newgetopt is 1 (one). A zero value indicates
that errors were found.

A new version of getopt is currently being developped that includes
abbreviations.

----------------- New address as of November 1, 1993 -------------------------

Stichting NLnet                                          Phone: +31 20 5924245
Kruislaan 413, 1098 SJ Amsterdam, The Netherlands          Fax: +31 20 5924199
------------------------ "Arms are made for hugging" -------------------------
--
----------------- New address as of November 1, 1993 -------------------------

Stichting NLnet                                          Phone: +31 20 5924245
Kruislaan 413, 1098 SJ Amsterdam, The Netherlands          Fax: +31 20 5924199



Mon, 20 May 1996 00:15:20 GMT  
 any additional docs for newgetopt.pl?

Quote:
Johan writes:

:A new version of getopt is currently being developed
:that includes abbreviations.

Neat.  

Mind you, I've never been very impressed with
getopts.  Maybe I'm just spoiled.

A challenge for Perl5 will be library enhancements
while providing compatibility, at least, if you
use the same name for the function, which is
sometimes desirable.  You can't just check $[,
cause it wouldn't even compile under Perl4 if you
use Perl5 stuff.  Also, you could have a Perl5 binary
but an old program that was using the library expecting
Perl4 semantics. Yucko.

I'm not sure I like 17 varyingly-named getopt programs.  
Can we merge these at all?

Have you consider letting people use at %Options table?  This
seems nicer than $opt_blah for many rather obvious reasons.

Of course, I still don't know how you deal wiht
    -a -a

Would that set $Opt{'a'} to 2?  How does it
differ from

    -a=2

Sigh.  Maybe parseargs() can handle that.

Do you handle abbreviations?


scoped global?  Do you pass in a a reference for cleanliness or a
typeglob for Perl4 programs?  Do you pass in a table to load the
options into?

There are so many schemes.  I have an mh-opt-parser somewhere as well.

--tom
--

      "Will Hack Perl for Fine Food and Fun"
        Boulder Colorado  303-444-3212



Mon, 20 May 1996 01:22:14 GMT  
 any additional docs for newgetopt.pl?

Quote:

> I'm not sure I like 17 varyingly-named getopt programs.  
> Can we merge these at all?

> Have you consider letting people use at %Options table?  This
> seems nicer than $opt_blah for many rather obvious reasons.

Hello;

Here's more getopt fuel... announcing evaluate_parameters 2.0 for C and
Perl.
I've spent alot of time on this code and added lots of new features.
Briefly,
evaluate_parameters parses a command line, performs type-checking on
parameter values and provides three levels of online help.  Here are some
key features, the offical announcement doc follows:

 - Works for either Perl 4 or Perl 5.  The few Perl 5 constructs are hidden
   within evals.
 - The information describing a command's parameters is defined with a
   syntax similar to C/Pascal function prototypes.  It declares parameter
   names, abbreviations, types, default values, environment variables and
   whether or not the parameter is a list.
 - Parameters can be assigned default values, which may be an environment
   variable.  If the special default value `$required' is specified
   evaluate_parameters ensures that the parameter is specified on the
   command line and is of the appropriate type.
 - Type-checking for these types: switch, string, real, integer, boolean,
   file, keyword, name and application.
 - All types except switch may be a list.
 - Parameter values are returned in global variables:  the `old' way in

   in the associative array %options.  If you use %options, Perl 4 lists
are
   returned as a string `joined' by the multi-dimensional array emulation
   character ($;), while Perl 5 lists are returned as a reference to a
list.
 - The parameters -usage_help, -help and -full_help are automatically
   defined and handled by evaluate_parameters so no code is required in
your
   application.
 - The auxiliary Perl program generate_tk_program can generate an X11
Tcl/Tk
   GUI front-end for any program using evaluate_parameters.  It
automatically
   creates and the necessary windows, widgets, buttons, scrollbars, etc.
It
   incorporates all the online help into a Text widget and captures STDOUT
   from the command's execution in a separate Toplevel window for saving or
   piping.
 - The auxiliary Perl program generate_man_page takes all the information
   you supply to evaluate_parameters and generates simple nroff man pages
so
   that your documentation is simply and automatically up-to-date.

Availability info follows at the end of this message.  Any problems,
comments
or whatever are very welcome.  Thanks and take care,

Steve
---------------------------------------------------------------------------
Sample Parameter Description Table (PDT) declarations:

        number, n: real = 123e-2
        user, u: string = `whoami`
        colors, c: list of key red, blue, green, yellow, keyend = $required
        verbose, v: switch
        scratch_file_name, sfn: file = D_SFN, /tmp/scratch

`number' (or `n') is a real number with a default value of 1.23.
`user' (or `u') is a string with a default value resulting from the
evaluation
                of the command `whoami'.
`colors' (or `c') is a list of keywords.  At least one value must be
specifed
                on the command line and it must be in the specified set of colors.
`verbose' (or `v') is a typical Unix standalone switch.
`scratch_file_name' (or `sfn') is a file name with a default value of
                /tmp/scratch.  However, if -sfn is not specified on the command
line
                and the environment variable D_SFN exists, evaluate_parameters
will
                use it as the parameter's default value.
---------------------------------------------------------------------------

                evaluate_parameters 2.0 for C and Perl

     evaluate_parameters, designed as a replacement for the getopt family
of
functions, is now available.  Briefly, evaluate_parameters parses a Unix
command line in a simple and consistent manner, performs type-checking on
parameter values and provides three levels of help on the command, its
parameters and their possible values.

    There are several advantages to using evaluate_parameters in all your C
and Perl programs:

 - Every program calling evaluate_parameters has a -help switch which
   lists all the command line arguments and their aliases, the types
   of parameter values they expect, and their default values.  Many Unix
   commands have no man pages so this first-level help is the only help
   available to a user.  This is provided automatically as part of
   evaluate_parameters; no code is required in your application.  

   An optional help message module can be defined to provide additional
   help for the command and all its parameters.  This information is
   displayed when -full_help is specified on the command line.

 - Because evaluate_parameters allows command line arguments to have an
   alias, parameters can be given meaningful names which a user can readily
   understand.  Hackers, on the other hand, can use the abbreviation to
   speed their work.

 - evaluate_parameters verifies that the value specified for a command
   line argument is of the appropriate type. Types currently supported are
   switch, string, real, integer, boolean, file, key, application and name.

   For C, parameter values are returned in a structure known as the PVT
   (Parameter Value Table) and are available in two forms; unconverted C
   strings and type-converted values.

   For Perl, since the language performs type conversion automatically,
you
   simply get the parameter's value in global variables:  the `old' way in

way
   in an associative array %options.  If you use %options, Perl 4 lists are
   returned as a string `joined' by the multi-dimensional array emulation
   character ($;), while Perl 5 lists are returned as a reference to a
list.

 - All parameter types except switch may be lists.

 - An auxiliary Perl program called generate_tk_program automatically
writes
   Tcl/Tk X11 Motif GUI wrappers for any program using evaluate_parameters.
   Tcl 7.0 and Tk 3.3 or above are required.  Here are the general
capabilities
   of programs created by generate_tk_program:

   . Command line parameters are specified via a form.  Most are Entry
widgets,
     except for parameters of type key, switch and boolean which are
     Radiobutton widgets.

   . For `list of' command line parameters we make these widget
distinctions:

        key             Checkbutton widget
        switch          not allowed
        other types     Entry widget with multiple space-separated items

   . Complete command and parameter help (from the evaluate_parameters
Message
     Module) displayed in a scrollable Text widget.

   . A scrollable Entry widget dynamically displays the command to be
executed.

   . After execution the command's standard output is captured in a
separate
     Toplevel window.  This window can be saved to a file or directed to a
     command pipeline.

   . Parameters are labelled with Button widgets rather than Label widgets
so
     clicking on a command line parameter Button positions the help window
     automatically to the help text for that parameter.  The scrollable
Entry
     widget is also repositioned to show the specified parameter.

   . Important items that should be highlighted for the user to see are
     displayed in a configurable background color using the X11 resource
name
     `name.highlight : color'.          

   . An Undo selection to reset all command line parameters to their
original
     values.

   . Usage help explaining the characteristics of applications generated by
     generate_tk_program, and details of evaluate_parameters.

   . The generated program dynamically determines if your Tk has the
AddInput
     extension, and uses non-blocking reads of standard output so that the
     command can be cancelled.  Without AddInput, the application will hang
if
     the Unix program never completes.

 - An auxiliary Perl program called generate_man_page automatically creates
a
   simple nroff man page for any program using evaluate_parameters.

 - evaluate_parameters interfaces cleanly with Xlib or Xt.

 - Your job of developing applications is simplified because you don't
waste
   time writing code to process arguments again, and again, and again!
   Command line parsing is simple, compact and consistent.  Adding or
changing
   command line parameters is extremely easy.

 - Most importantly, as long as you adhere to the Human Interface
Guidlines,
   evaluate_parameters provides for a consistent user interface across all
   your C and Perl programs.

                               Availability

Both the C and Perl implementations of evaluate_parameters are available
via
anonymous FTP from ftp.Lehigh.EDU (128.180.2.4).  Look in the pub/evap
directory for the latest compressed tar file.      

evaluate_parameters/C is known to work on AIX, EP/IX, HP-UX, IRIX, Sony
NEWS,
SunOS and TitanOS.  It has in the past also worked on VX/VE.

evaluate_parameters/Perl is known to work on AIX and MS-DOS.

Stephen O. Lidie
Lehigh University Computing Center




Mon, 20 May 1996 04:43:28 GMT  
 any additional docs for newgetopt.pl?

Quote:
>I'm not sure I like 17 varyingly-named getopt programs.  
>Can we merge these at all?

agreed. i would love to be able to use single-letter options (-n),
long options (--foo) with one all-encompassing function. it would
be even more keen if it supported non-ascii options (f'rinstance: -#)

-cgw-



Mon, 20 May 1996 06:10:16 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. abbrev.pl + newgetopt.pl = NEAT!

2. Changes to NGetOpt in newgetopt.pl

3. Source: newgetopt.pl version 1.14

4. Abbreviation support for newgetopt.pl

5. newgetopt.pl

6. Newgetopt.pl, version 1.13.

7. Official patch to newgetopt.pl 1.9

8. bug in newgetopt.pl

9. newgetopt.pl by Johan Vromans version 1.13

10. newgetopt.pl

11. newgetopt.pl dumps core

12. An additional open routine for chat2.pl

 

 
Powered by phpBB® Forum Software