Skip to content

Nested Subcommands with arguments do not work #6152

@matthiasbeyer

Description

@matthiasbeyer

Please complete the following tasks

Rust Version

1.90

Clap Version

4.5.48

Minimal reproducible code

use clap::Parser;
use clap::Subcommand;

#[derive(Parser)]
struct App {
    #[clap(subcommand)]
    command: Command,
}

#[derive(Clone, Debug, Subcommand)]
enum Command {
    Inner {
        #[clap(long, short)]
        foo: i32,
        
        #[clap(subcommand)]
        inner: Config,
    }
}

#[derive(Clone, Debug, Subcommand)]
enum Config {
    #[clap(subcommand)]
    Show,
    #[clap(subcommand)]
    Edit,
}

fn main() {
    App::parse_from(&["app", "inner", "--foo", "12", "show"]);
}

playground

Steps to reproduce the bug with the above code

Run playground

Actual Behaviour

Prints help text, which indicates the exact same that was passed

Expected Behaviour

Parses CLI correctly

Additional Context

No response

Debug Output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-deriveArea: #[derive]` macro APIC-bugCategory: bugS-waiting-on-designStatus: Waiting on user-facing design to be resolved before implementing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions