Re: show help if no input
Duke <[email protected]> Wed, 18 Aug 2010 17:05:13 -0400
| Newsgroups | gmane.comp.gnu.gengetopt.general |
|---|---|
| Message-ID | <[email protected]> |
On 8/18/10 2:35 PM, Lorenzo Bettini wrote:
> when you use -h|--help, but you must have generated the command line
> parser with
>
> -l, --long-help long usage line in help
>
> (this is an option to be passed to gengetopt)
>
> then, when print the output of help you'll have something similar
>
> Usage: sample1 -iINT|--int-opt=INT [-h|--help] [--detailed-help]
> [--full-help]
> [-V|--version] [-sfilename|--str-opt=filename]
> [-mINT|--my-opt=INT]
> [--flag-opt] [-F|--funct-opt] [--long-opt=LONG]
> [--def-opt=STRING]
> [--enum-opt=STRING] [-DINT|--dependant=INT] [FILES]...
>
>
Oh I see. Thanks.
> by the way, I've just realized there's already something for this (see
> also the manual):
>
> --show-required
> if --show-required is given, possibly with a string, in the output
> of --help will be made explicit which options are actually required,
>
Yes, --show-required does the job. The required options now have
"(mandatory)" string.
> I meant something different: before invoking
>
> cmdline_parser (argc, argv, &args_info) != 0
>
> you could do something similar (not checked it myself)
>
> if (argc < 2) {
> cmdline_parser_init (&args_info);
> cmdline_parser_print_version(void);
> return -1;
> }
>
Yes, it does exactly as I wanted. "cmdline_parser_init (&args_info);" is
the command I tried to look for but couldnt. I know I will have to init
it before the parser, but just dont know which command to do that.
Thank you very much Lorenzo, all problem solved now.
D.
> does this do what you need?
>
> please, let me know
> cheers
> Lorenzo
>