Skip to content

Can't get colors to print... #5419

Answered by epage
cylewitruk asked this question in Q&A
Mar 24, 2024 · 2 comments · 4 replies
Discussion options

You must be logged in to vote

Note that the following works:

fn main() -> Result<()> {
    let cli = Cli::parse();
    match cli.command {
        MySubCommands::Foo(_) => {
            println!("Running foo");
        }
        MySubCommands::Bar => {
            println!("Running bar");
        }
    }

    Ok(())
}

To better understand why that works but it doesn't work in your case, let me create a middle ground. The above is almost but not quite

fn main() -> Result<()> {
    match Cli::try_parse() {
        Ok(cli) => match cli.command {
            MySubCommands::Foo(_) => {
                println!("Running foo");
            }
            MySubCommands::Bar => {
                println!("Running bar");

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@epage
Comment options

Answer selected by cylewitruk
@cylewitruk
Comment options

@epage
Comment options

@cylewitruk
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants