Skip to content

Detailed help for ValueEnum variants #6096

@epage

Description

@epage

Discussed in #6070

Originally posted by timmc July 13, 2025
I have a ValueEnum with variants that have detailed help (that is, more than one paragraph of doc comments). How can I get clap to show this when --help is invoked?

Example using clap 4.5.1:

use clap::{Parser, ValueEnum};

#[derive(Clone, Debug, ValueEnum)]
enum Multi {
    /// Foo short help.
    ///
    /// Foo detailed help. This should be exposed in --help.
    Foo,
    /// Bar short help.
    ///
    /// Bar detailed help. This should be exposed in --help.
    Bar,
}

#[derive(Clone, Debug, Parser)]
struct Cli {
    myopt: Multi,
}

pub fn main() {
    Cli::parse();
}

Output from --help:

Usage: clap_demo <MYOPT>

Arguments:
  <MYOPT>
          Possible values:
          - foo: Foo short help
          - bar: Bar short help

Options:
  -h, --help
          Print help (see a summary with '-h')

I'd like some way of exposing the full docstring of Foo and Bar in the myopt help string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-helpArea: documentation, including docs.rs, readme, examples, etc...C-bugCategory: bugE-easyCall for participation: Experience needed to fix: Easy / not muchM-breaking-changeMeta: Implementing or merging this will introduce a breaking change.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions