mylang_cli_test/
main.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use std::io;

use clap::Parser;
use mylang_cli_ext::{CommandFromParserExt, MatchesFromParser, WithOutputExt};

#[derive(Parser)]
struct Cli {
    input: Option<String>,
}

fn main() -> anyhow::Result<()> {
    let cmd = Cli::to_command().with_output();
    let matches = cmd.get_matches();
    let Cli { input } = matches.parse();
    println!("input: {:?}", input);
    let stdout = io::stdout();
    let _dest = matches.output(&stdout)?;
    Ok(())
}