1. Docs: The example for

Here's the function signature, both from the docs and from the code:

include std/cmdline.e 
public procedure show_help(sequence opts, object add_help_rid = - 1, sequence cmds = command_line()) 

And here's the example:

-- in myfile.ex  
constant description = {  
       "Creates a file containing an analysis of the weather.",  
       "The analysis includes temperature and rainfall data",  
       "for the past week."  
    }  
 
show_help({  
    {"q", "silent", "Suppresses any output to console", NO_PARAMETER, -1},  
    {"r", 0, "Sets how many lines the console should display", {HAS_PARAMETER,"lines"}, -1}},  
    description)  

Note that the first parameter is a sequence of option descriptions, and the second parameter is supposed to be a routine ID. The example given has a second parameter of a sequence of characters.

I didn't see any handling for that in the code. In fact, even though "add_help_rid" is assigned as an object it is first used in a boolean expression to compare it to -1.

Or am I reading it wrong? I did try the example standalone as written and it did error out.

new topic     » topic index » view message » categorize

2. Re: Docs: The example for

The example for cmd_parse has a few errors in it too:

The procedure opt_extras refers to option_definition as option_definitions (the extra 's' causing an error)

The example uses the short option 'h' for 'hash'. cmd_parse complains that you cannot reuse a short definition (I believe standardize_opts uses 'h' for 'help'). I changed it to 'z'.

This was the second bug, and it confused me because it reported line 33 as causing the error (which assigned a value to option_definition) instead of line 41 (the actual call to cmd_parse). I was confused by this, although hindsight shows me that 33 was where the error was located. I don't know if this was coincidence or intended behavior (any sufficiently advanced bug is indistinguishable from a feature).

Another bug causing the example to crash:
opt_verbose should be declared as a function and return a value (1 in this case, I think??)

As output I get:

test-cmd_parse.ex options: 
   [-v], [--verbose]      Verbose output 
   [-z], [--hash]         Calculate hash values 
   -o x, --output=x       Output filename 
   [-i x], [--import=x]   An import path 
   [-h], [--help]         Display the command options 
   [-?]                   Display the command options 
One or more additional arguments can be supplied. 

Editing this: once I created the "output.txt" file, now I get another error. Seems "opt_output" should be a function too.

new topic     » goto parent     » topic index » view message » categorize

3. Re: Docs: The example for

cmd_parse (and helpers) have undergone several revisions. I think somewhere along the line the ability to send just an additional description was lost but the example was not updated.

I've created a bug report because the ability to send an additional description as text is helpful. Many times a full blown routine will not be needed to describe additional functionality. Bug # 2848906.

Jeremy

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu