zig-clap icon indicating copy to clipboard operation
zig-clap copied to clipboard

Support CLI description lines when parsing parameters

Open tensorush opened this issue 1 year ago • 1 comments

Hi, I was wondering if it's possible to support skipping cli description lines before parsing parameters?

const PARAMS = clap.parseParamsComptime(
    \\my-package-name - My Package Description [v0.1.0]
    \\
    \\-o, --opt <u8>   Optional argument (default: 3)
    \\-h, --help       Display help
    \\<str>            Positional argument
    \\
);

tensorush avatar Feb 23 '25 08:02 tensorush

It's not really something I want to bake into parseParamsComptime specifically. Seems pretty specific. Maybe in the future there is a function called parseHelp that parses an entire help message and not just the parameters.

What you can do as a workaround is something like this:

const help_description =
    \\my-package-name - My Package Description [v0.1.0]
    \\
;

const help_parameters =
    \\-o, --opt <u8>   Optional argument (default: 3)
    \\-h, --help       Display help
    \\<str>            Positional argument
    \\
;

const help_full = help_description ++ help_parameters;

const patameters = clap.parseParamsComptime(help_parameters);

Hejsil avatar Feb 23 '25 11:02 Hejsil