Skip to content

Mapping raw args to desired type on-the-fly similar to serde_with::TryFromInto #6118

@MrFoxPro

Description

@MrFoxPro

Clap Version

4.5.42

Describe your use case

Due to limitations of clap, it's not always possible to get desired type from CLI: example.
Same thing applies to serde, but there is convenient macro serde_with::TryFromInto, which allows in combination with #[serde(flatten)] to map values into desired type.

Describe the solution you'd like

Something like serde_with::TryFromInto, but for clap.

Additional Context

It's difficult to transform CLI input to different type, especially if there are multiple nested subcommands. Right now it requires a lot of boilerplate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-deriveArea: #[derive]` macro APIC-enhancementCategory: Raise on the bar on expectations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions