From 0ae5e3b93ebcec299619f04da09c024705c98098 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Tue, 8 Feb 2022 15:13:36 -0800 Subject: feat(cli): config compiler show subcommand --- crates/divina/src/cli.rs | 20 +++++++++++++++++--- crates/divina_compile/src/lib.rs | 7 +++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/crates/divina/src/cli.rs b/crates/divina/src/cli.rs index 6a843b7..c256927 100644 --- a/crates/divina/src/cli.rs +++ b/crates/divina/src/cli.rs @@ -17,9 +17,7 @@ fn cli() -> App<'static, 'static> { .takes_value(true) .possible_values(&["bin", "lib"]), Arg::with_name("git").long("git").takes_value(true), - Arg::with_name("path") - .index(1) - .takes_value(true), + Arg::with_name("path").index(1).takes_value(true), ]), SubCommand::with_name("build").about("Build your project"), SubCommand::with_name("clean") @@ -30,6 +28,12 @@ fn cli() -> App<'static, 'static> { .subcommands(vec![ SubCommand::with_name("show").about("Print your configuration"), SubCommand::with_name("validate").about("Check if your configuration will compile"), + SubCommand::with_name("compiler") + .about("Access the Divina compiler wrapper") + .setting(AppSettings::SubcommandRequiredElseHelp) + .subcommands(vec![ + SubCommand::with_name("show").about("Print Divina's compiler configuration") + ]), ]), ]) .args(&[ @@ -71,6 +75,16 @@ pub fn execute(divina: &mut crate::Divina) { match s_matches.subcommand() { ("show", _) => divina.print_config(), ("validate", _) => println!(":: no issues found"), + ("compiler", Some(s_s_matches)) => + match s_s_matches.subcommand() { + ("show", _) => { + let _ = divina + .compiler + .find_sources(&divina.expose_config().clone()) + .print_config(); + } + _ => unreachable!(), + }, _ => unreachable!(), }, _ => unreachable!(), diff --git a/crates/divina_compile/src/lib.rs b/crates/divina_compile/src/lib.rs index ec37f6d..603066e 100644 --- a/crates/divina_compile/src/lib.rs +++ b/crates/divina_compile/src/lib.rs @@ -283,6 +283,13 @@ impl Compiler { } } } + + #[must_use] + pub fn print_config(&self) -> &Self { + println!("{:?}", self); + + self + } } #[cfg(windows)] -- cgit v1.2.3