http://www.perlmonks.org?node_id=549577

QM has asked for the wisdom of the Perl Monks concerning the following question:

I've had to add multiple option lists to a Getopt::Declare option spec, like so:
my $spec = qq{ [nocase] [strict] Description: $0 massages WAT, WS, FT, and SLT data into one output file, matchi +ng on DIE ID and WAT site. Options: -map <map_file:if> reticle to die_id YAML file created by anoth +er script [required] -wat <wat_files:if>... , list of WAT files, in CSV format. (Normally the WAT files come in Excel XLS format, just save as + CSV.) -ws <ws_files:if>... , list of WS files. -ft <ft_files:if>... , list of FT files. -slt <slt_files:if>... , list of SLT files. };
Note: to get the lists to play nicely together, I had to add a list terminator. Otherwise, the next option is seen as the next item on the current list. (For lack of inspiration, I chose comma as the terminator.)

Is there a way to make this work without the list terminator? It's especially egregious on the last list, but the options can be in any order. Also, users are complaining about missing data, "weird" error messages, etc., all attributed to incorrect command line options (e.g., no whitespace around commas).

I'd really like to make this more user friendly, but I've got coder's block or something.

-QM
--
Quantum Mechanics: The dreams stuff is made of

Replies are listed 'Best First'.
Re: Getopt::Declare: multiple option lists require terminators?
by TheDamian (Vicar) on May 16, 2006 at 20:12 UTC
    It's a bug in the module. I have a fix that I've not yet had time to release. If you'd like the beta, email me.

    Damian

      The bug ist still present in 1.11 ! Can you post the fix? Danijel
Re: Getopt::Declare: multiple option lists require terminators?
by MonkE (Hermit) on May 16, 2006 at 13:31 UTC
    Instead of -ws <ws_files:if>... ,    list of WS files. have you tried: -ws <ws_file> [repeatable] (untested)?

    Of course your actual usage syntax would change to -ws file1.ws -ws file2.ws and so on.
      That's a useful suggestion, and it works like this:
      -ws <ws_file:if> WS input file { push \@::list, \$ws_file; } [repeatable]
      However, then every input file would require its own option flag. Wildcards would have to be massaged before calling G::D->new() (not such a bad thing, as they already are, but it's more work and more places to cause problems).

      Another idea is to omit the list terminator from the spec, and preprocess the options to put an option flag in front of every unadorned file name. But then, if I'm going to do all that, I might as well process the options myself. :(

      -QM
      --
      Quantum Mechanics: The dreams stuff is made of