clap_fmt
Serialize clap structs back into command-line arguments.
Overview
clap_fmt allows you to take a struct that derives clap::Parser and serialize it back into the command-line arguments that would produce that struct.
Usage
Add to your Cargo.toml:
[]
= "4"
= "0.1"
= { = "1", = ["derive"] }
FmtArgs on your clap struct:
use Parser;
use FmtArgs as _;
use Serialize;
Features
- Supports all common clap argument types:
- Boolean flags
- Options with values
- Multiple values and repeated arguments
- Positional arguments
- Subcommands (including nested)
- Count flags (
-vvv) - Value enums
- Handles default values correctly (omits them from output)
- Preserves argument order semantics
- Works with both short (
-v) and long (--verbose) arguments
License
MIT