Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Usage: including positional arguments in a mutually-exclusive group renders them in the wrong order #5625

Open
Labels
A-helpArea: documentation, including docs.rs, readme, examples, etc...C-bugCategory: bugS-waiting-on-designStatus: Waiting on user-facing design to be resolved before implementing
@jrose-signal

Description

@jrose-signal

Please complete the following tasks

Rust Version

1.80.0

Clap Version

4.5.11

Minimal reproducible code

use clap::*;// 4.5.11#[derive(Parser)]structTopLevel{first:String,#[command(flatten)]second:Inner,}// *** Note: the user can specify *either* a positional argument *or* a named argument#[derive(Args)]#[group(required =true, multiple =false)]structInner{value:Option<String>,#[arg(long)]path:Option<String>,}fnmain(){letmut cmd =TopLevel::command();    _ = cmd.print_long_help();let parsed =TopLevel::parse_from(["test","a","b"]);assert_eq!(parsed.first,"a");assert_eq!(parsed.second.value,"b");}

Steps to reproduce the bug with the above code

Run on play.rust-lang.org

Actual Behaviour

Usage: playground <VALUE|--path <PATH>> <FIRST>

even though the assertions show that theFIRST argument is in fact getting parsed first, as desired.

Expected Behaviour

Usage: playground <FIRST> <VALUE|--path <PATH>>

It does work to put the flag argument after the first positional argument, so this isn't even wrong, even if it's a little unconventional.

Additional Context

I tried manually specifyingindex on the arguments, but it did not affect the help output.

Debug Output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-helpArea: documentation, including docs.rs, readme, examples, etc...C-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


      [8]ページ先頭

      ©2009-2025 Movatter.jp