GetOpt::Long - Corequisite options? 
Author Message
 GetOpt::Long - Corequisite options?

Hello all,

I've been scouring the docs for GetOpt::Long and haven't seen
anything that deals with corequisite options.  Has anybody
done this kind of thing already?

What I'd like to do is require the user to use -blech if they
have specified option -bar.  I can do this with a pile of
"if" statements but I would prefer the tidiness and consistency
of a package.  If there is enough interest I will put something
together and bounce it off Johan.

Another thought.  Perhaps it would be simpler to use one option
but to require two arguments.  I don't see a method for doing
this either.

cheers,
Bryan



Sun, 16 Jan 2000 03:00:00 GMT  
 GetOpt::Long - Corequisite options?

Quote:

> What I'd like to do is require the user to use -blech if they
> have specified option -bar.

This sounds simple, but it is really a complex matter. Next thing you
will probably want is GetOptions to check filenames, verify that
they are existing (or not), readable, writable, and so on :-).

But seriously: how would you define this requirement?
Would you require a specific order of options?
Could you give a detailed example of what you think is useful?

Quote:
> I can do this with a pile of "if" statements but I would prefer the
> tidiness and consistency of a package.

A "pile of if statements" is usualy required anyway for complex sets
of options. Often values of options are related.

Quote:
> Another thought.  Perhaps it would be simpler to use one option
> but to require two arguments.  I don't see a method for doing
> this either.

I use an array-type option for this, plus some added flexibility:


This will allow "-foo bar -foo blech" as well as "-foo bar,blech" (and
combinations).

Hmm. I could add support for this in Getopt::Long.

-- Johan



Mon, 17 Jan 2000 03:00:00 GMT  
 GetOpt::Long - Corequisite options?

: What I'd like to do is require the user to use -blech if they
: have specified option -bar.  I can do this with a pile of
: "if" statements but I would prefer the tidiness and consistency
: of a package.  If there is enough interest I will put something
: together and bounce it off Johan.

Please do.  Also notethat because sometimes the order of options
matters there must be also pre- and postrequisite options.

--
$jhi++; # http://www.iki.fi/~jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen



Mon, 17 Jan 2000 03:00:00 GMT  
 GetOpt::Long - Corequisite options?


: > What I'd like to do is require the user to use -blech if they
: > have specified option -bar.

: This sounds simple, but it is really a complex matter. Next thing you
: will probably want is GetOptions to check filenames, verify that
: they are existing (or not), readable, writable, and so on :-).

I realise it's complex.  That's why I'd prefer to avoid reinventing
the wheel =:o  Actually, I was planning on writing it and submitting it
if it doesn't exist.  I'm not really asking for anything except a
heads up if someone already has done this.

: But seriously: how would you define this requirement?
: Would you require a specific order of options?

No.  Order is not important in the canonical definition
of corequisite.

: Could you give a detailed example of what you think is useful?

Perhaps there exists a utility called difftest that works in two
modes; single file pair comparisons and multiple file pair comparisons.

% difftest results.out results.ORIG

works well but how about allowing the user to pass the suffix
for "old" and "new" test results instead of globs (*.out, *.ORIG -
which is an even more difficult problem.  How does one separate

% difftest -new out -old ORIG

Neither option is good without the other in the latter mode so it
would be nice to ensure that both are used.

: I use an array-type option for this, plus some added flexibility:


Actually, I used to use this frequently on Digital Unix boxes
that dump core on GetOptions.  This may be the quick and easy

Let me play around with this.  There's more than one way to do
it :-)

Bryan



Mon, 17 Jan 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Getopt:Long arguments that are not (options or option values)

2. Problem checking if a command line option has been specified using Getopt::Long

3. ANNOUNCE: Getopt::Long 2.9 -- Universal command line options processing

4. ANNOUNCE: Getopt::Long 2.6 -- Universal command line options processing

5. Using Getopt::Long with multiple options in quotes

6. Getopt::Long and Options in single quotes?

7. Getopt::Long, using '?' as option

8. ANNOUNCE: Getopt::Long 2.9 -- Universal command line options processing

9. ANNOUNCE: Getopt::Long 2.6 -- Universal command line options processing

10. Getopt::Long need a '-?' option

11. Tk-Options-0.10: Interface to Getopt::Long and Tk

12. getopt() for multicharacter options?

 

 
Powered by phpBB® Forum Software