develooper Front page | perl.perl5.porters | Postings from April 2003

Re: [PATCH 5.8.1 @19053] Getopt::Std

Thread Previous
Ilya Zakharevich
April 2, 2003 12:23
Re: [PATCH 5.8.1 @19053] Getopt::Std
Message ID:
On Wed, Apr 02, 2003 at 10:04:00AM +0200, Rafael Garcia-Suarez wrote:
> > +sub version_mess ($;$) {
> I don't understand what the 2nd argument is for ? it's not used.
> Do you have further plans about it ? (same remark for help_mess)

It is used (oups, see below).  If present, it would check for the
user-supplied version.  When called from the user-supplied version (so
without the second argument, per docs ;-), it would just print the
"stupid" best-it-can-do part.

BTW, it would probably be better if the line "Usage: stupid" be not
printed when called without the second argument...

> > +    my $args = shift;
> > +    if (@ARGV and defined &main::VERSION_MESSAGE) {

Drat! It's s'@ARGV'@_'!

> I'd replace $] by some modern-looking and non-backportable sprintf("%vd",$^V).

Conditional on $] > ..., I hope?  ;-)

I do not think Getopt::Long can do the same now?  If/when adding a
similar feature to Getopt::Long, the following should be taken into

  a) There should be a way to associate a help string to the option
     (IIRC, it was already done circa 5 years ago; at least it was discussed);

  b) There should be a way to insert a "separator" into the option
     list (similar to =head1, =head2, =head3 of POD).  This way the
     option list is made into a tree.  The separators are ignored
     during the normal processing, but may be used for --help and for 
     the case when Getopt::Long actually calls a GUI to set options.

     The separator should have 3 attributes: level, title, and help
     text.  When processing --help, help text is written immediately after
     the title (with indentation set by level).

     The simplest way to insert a separator is something like

	["input|i=s", argname => 'PATCHFILE',
	  help => 'Read patch from PATCHFILE instead of stdin.'],
	GetOpt::Long::Separator(1, 'Output options:', ''),
	["output|o=s", argname => 'FILE',
	  help => 'Output patched files to FILE.']

     which on --help would produce something like the `patch --help'

  -i PATCHFILE  --input=PATCHFILE  Read patch from PATCHFILE instead of stdin.

Output options:

  -o FILE  --output=FILE  Output patched files to FILE.

  c) There should be a way to request/suppress sorting of options on --help.

  d) GUI Getopt may use the separators to organize the GUI into pages.
     The style of pages is up to the GUI: it may be Window-style
     wizard pages, or a notebook, or a Netscape-config style
     collapsible-tree-of-page-names with the page on the side.

     This is out of Getopt::Long scope, but:

  e) What is important is for user to be able to choose the GUI at
     runtime.  I propose the common option (script-independent)


    If Getopt::Long finds this option, it should try to delegate work
    to Getopt::Foo, if not present to Getopt::Bar, if not present,
    this option is ignored.  Or maybe make --getopt-gui into a boolean
    and get the preference list from %ENV?


Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About