help-gengetopt
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [help-gengetopt] Re: GNU Gengetopt 2.16


From: Lorenzo Bettini
Subject: Re: [help-gengetopt] Re: GNU Gengetopt 2.16
Date: Sun, 26 Mar 2006 21:44:06 +0200
User-agent: Mail/News 1.5 (X11/20060228)

Andre Noll wrote:
On 19:31, Lorenzo Bettini wrote:
Wouldn't it be a good thing to use a #define or two in xyz.cmdline.h
which holds the help text?
that's another good idea! :-)

I'll make the help string available so that one can print it anywhere!

I guess the best way would be an array of strings, what do you think?

At the moment we have the following strings that get printed
by cmdline_parser_print_help():

        PACKAGE
        VERSION
        the usage string (e.g. "Usage: xyz [OPTIONS]...")
        automatic options (--help, --version)
        other options (the real options determined by the .ggo file)

The simple solution I had in mind was to introduce some
macros, (say USAGE, AUTOMATIC_OPTIONS, OTHER_OPTIONS) so that
cmdline_parser_print_help() is equivalent to

        printf("%s %s\n", PACKAGE, VERSION);
        printf("%s\n\n", USAGE);
        printf("%s\n", AUTOMATIC_OPTIONS);
        printf("%s\n", OTHER_OPTIONS);

This has the disadvantage that one can only print the help for all
options together.

A more general possibility would be to extend the args_info struct
such that it also contains the help text for each option. For example,
if there is an option called --foo, generate a foo_help member in
args_info, much like foo_given and foo_arg which we already have.

This approach solves the above problem but it makes it difficult to
get the complete help text.

So maybe you are very right and the best way to go is using an array.
We could combine this with the foo_help thing by first doing

        const char *args_info_help[] = {
                "  -h, --help                    Print help and exit",
                "  -V, --version                 Print version and exit"
                "  -f, --foo                        set foo (default=`42')",
                "  -b, --bar                        set bar (default=`43')",
                ,,,
        }

and then in clear_args()

        args_info.foo_help = args_info_help[0];
        args_info.bar_help = args_info_help[1];
        ...

As the help texts may be quite big, we should store it only once
to avoid bloat.

Regards
Andre

Hi

I've put up a release candidate that implements this feature (please take a look at the documentation):

here's the temporary link

http://rap.dsi.unifi.it/~bettini/gengetopt-2.17rc.tar.gz

hope to hear from you soon
cheers
        Lorenzo

--
+-----------------------------------------------------+
|  Lorenzo Bettini          ICQ# lbetto, 16080134     |
|  PhD in Computer Science                            |
|  Dip. Sistemi e Informatica, Univ. di Firenze       |
|  Florence - Italy        (GNU/Linux User # 158233)  |
|  Home Page        : http://www.lorenzobettini.it    |
|  http://music.dsi.unifi.it         XKlaim language  |
|  http://www.purplesucker.com Deep Purple Cover Band |
|  http://www.gnu.org/software/src-highlite           |
|  http://www.gnu.org/software/gengetopt              |
|  http://www.lorenzobettini.it/software/gengen       |
|  http://www.lorenzobettini.it/software/doublecpp    |
+-----------------------------------------------------+




reply via email to

[Prev in Thread] Current Thread [Next in Thread]