// src/main.rs:10
// CLI subcommand is delegated to a submodule
match app.command {
Command::Init(options) => init::init(&options)?,
Command::New(options) => new::new(&options)?,
Command::Build => build::build()?,
};
Single responsibility principle
// src/init.rs
// Each module is responsible for a single use case, takes own parameter object, etc.
pub fn init(Options { site_dir }: &init::Options) -> Result<(), Error> {
// ...
}
(almost) applicable to Rust code
Each module (function + options struct) could be make into a Command, but according to YAGNI, I did not :)