Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anyone interested in enhancements to the arg module? #3393

Closed
vicuna opened this issue Jun 15, 2002 · 1 comment
Closed

Anyone interested in enhancements to the arg module? #3393

vicuna opened this issue Jun 15, 2002 · 1 comment

Comments

@vicuna
Copy link

vicuna commented Jun 15, 2002

Original bug ID: 1200
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)

Bug description

Hi,

One feature that (I think) Module Arg could benefit by is more
descriptive and automated help. I'd like to have a

Arg.Symbol of (string * 'a) list * ('a -> unit)

such that when it is necessary to dump the help messages the
constructs

"-foobar", Arg.Symbol (["foo",Foo; "bar",Bar], foobar_handler, "foobar?");

"-sex", Arg.Symbol (["male",Male; "female",Female], sex_handler, "sex");

would print as

-foobar [foo|bar] foobar?

-sex [male|female] sex

It is easy enough to emulate this action except for the behavior of
the help message. Maybe you could supply a mechanism for customizing
the help message?

It would also be nice if the message for Arg.String and Arg.Int,
etc. mentions that the options takes an argument of the specified
type. This might make some of the messages a little less descriptive.
For example instead of

-cc Use as the C compiler and linker

it would now say

-cc string Use as the C compiler and linker

I know that in ocamlc you guys a real cool mechanism for the -w
feature but I'm not sure how to automate that.

I'm happy to write the code but I'm not sure if anyone is interested
in it. If you are send me a note and some of your requirements and
I'll go to town.

-cheers

@vicuna
Copy link
Author

vicuna commented Nov 2, 2002

Comment author: administrator

One feature that (I think) Module Arg could benefit by is more
descriptive and automated help. I'd like to have a

Arg.Symbol of (string * 'a) list * ('a -> unit)

I have tried to implement this, but it needs modifications. The compiler
complains that the type variable 'a is not bound. If I bind it as an
argument to the "spec" type, then we have two problems:

  1. It is an incompatible change.
  2. It forces all your Symbol options to use the same 'a type.

So what I have done is:
Arg.Symbol of string list * (string -> unit)

And it is your function that has to turn the string into whatever it
needs. One problem with this solution is that your list of symbols
will appear twice in the program (in your function, and in your spec
list).

Another way of doing things would be to give one function for each
symbol, like this:
Arg.Symbol of (string * (unit -> unit)) list

But I don't much like this solution, as it is really heavyweight.
If you have a better idea, please tell me.

"-foobar", Arg.Symbol (["foo",Foo; "bar",Bar], foobar_handler, "foobar?");
"-sex", Arg.Symbol (["male",Male; "female",Female], sex_handler, "sex");

would print as

-foobar [foo|bar] foobar?
-sex [male|female] sex

Pretty much, but square brackets usually denote optional arguments,
so I have used curly braces.

Implemented in the current working version (3.06+14).

It would also be nice if the message for Arg.String and Arg.Int,
etc. mentions that the options takes an argument of the specified
type. This might make some of the messages a little less descriptive.
For example instead of
-cc Use as the C compiler and linker
it would now say
-cc string Use as the C compiler and linker

I don't like it much, but if you want your program to do it, you
can already do it: just write your documentation strings accordingly.

-- Damien

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant