Pattern Matching CLI commands with Rust
I’m building a CLI tool using Rust, and I ran into some difficulties figuring out the best way to work with the structopts crate using subcommands to break out my logic into separate functions. I suspect this is because I am new to Rust, but I felt it was worth documenting the challenge and solution. I’ll use a fake tool to demonstrate the pattern I used. Let’s say the tool is called ecko, and it is used to print two different kinds of messages: hellos and goodbyes.