Skip to content

demo.md is doesn't match the output of demo --help #6098

@winksaville

Description

@winksaville

Please complete the following tasks

Rust Version

rustc 1.89.0 (29483883e 2025-08-04)

Clap Version

4.5.43

Minimal reproducible code

use clap::Parser;

/// Simple program to greet a person
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
struct Args {
    /// Name of the person to greet
    #[arg(short, long)]
    name: String,

    /// Number of times to greet
    #[arg(short, long, default_value_t = 1)]
    count: u8,
}

fn main() {
    let args = Args::parse();

    for _ in 0..args.count {
        println!("Hello {}!", args.name);
    }
}

Steps to reproduce the bug with the above code

I created a new repo with:

cargo new demo
cd demo
cargo add clap --features derive`

Changed main.rs to the above code and then installed it:

$ cargo install --path .
  Installing demo v0.1.0 (/home/wink/data/prgs/clap/demo)
    Updating crates.io index
     Locking 30 packages to latest Rust 1.89.0 compatible versions
   Compiling proc-macro2 v1.0.95
   Compiling unicode-ident v1.0.18
   Compiling utf8parse v0.2.2
   Compiling anstyle-query v1.1.4
   Compiling anstyle v1.0.11
   Compiling is_terminal_polyfill v1.70.1
   Compiling colorchoice v1.0.4
   Compiling strsim v0.11.1
   Compiling heck v0.5.0
   Compiling clap_lex v0.7.5
   Compiling anstyle-parse v0.2.7
   Compiling anstream v0.6.20
   Compiling clap_builder v4.5.43
   Compiling quote v1.0.40
   Compiling syn v2.0.104
   Compiling clap_derive v4.5.41
   Compiling clap v4.5.43
   Compiling demo v0.1.0 (/home/wink/data/prgs/clap/demo)
    Finished `release` profile [optimized] target(s) in 3.18s
   Replacing /home/wink/.cargo/bin/demo
    Replaced package `demo v0.1.0 (/home/wink/data/prgs/clap/demo)` with `demo v0.1.0 (/home/wink/data/prgs/clap/demo)` (executable `demo`)

Actual Behaviour

$ demo --help
Simple program to greet a person

Usage: demo [OPTIONS] --name <NAME>

Options:
  -n, --name <NAME>    Name of the person to greet
  -c, --count <COUNT>  Number of times to greet [default: 1]
  -h, --help           Print help
  -V, --version        Print version

Expected Behaviour

Based on the the documentation behavior should be:

$ demo --help
A simple to use, efficient, and full-featured Command Line Argument Parser

Usage: demo[EXE] [OPTIONS] --name <NAME>

Options:
  -n, --name <NAME>    Name of the person to greet
  -c, --count <COUNT>  Number of times to greet [default: 1]
  -h, --help           Print help
  -V, --version        Print version

Additional Context

Actually, this can be fixed by changing demo.md or demo.rs, I am preparing a PR.

Debug Output

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: documentation, including docs.rs, readme, examples, etc...C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions