From 4f44e2e97ecd099a272e39dd2fa1ee1a1dba709c Mon Sep 17 00:00:00 2001 From: Sebastian Kuzminsky Date: Sat, 5 Apr 2025 10:59:03 -0600 Subject: [PATCH] parser: start adding subcommands to the CLI --- tools/src/bin/parser/main.rs | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/tools/src/bin/parser/main.rs b/tools/src/bin/parser/main.rs index 27c7919..7ed5234 100644 --- a/tools/src/bin/parser/main.rs +++ b/tools/src/bin/parser/main.rs @@ -3,13 +3,25 @@ use clap::Parser; #[derive(Debug, clap::Parser)] #[command(version, about, long_about = None)] struct Args { - /// The name of the recipe to build. - target: String, - /// Directories containing repos. #[arg(short, long)] - // repo: String, repo: Vec, + + /// Type of behavior/output. + #[command(subcommand)] + command: Commands, +} + +#[derive(clap::Subcommand, Debug)] +enum Commands { + Mdbook { + /// The name of the recipe to create MD Book for. + target: String, + }, + Info { + /// The name of the recipe to show info for. + target: String, + }, } fn main() -> anyhow::Result<()> { @@ -20,8 +32,16 @@ fn main() -> anyhow::Result<()> { repos.add_repo(repo_path)?; } - let build_plan = repos.compile(&args.target)?; - build_plan.make_mdbook()?; + match &args.command { + Commands::Mdbook { target } => { + let build_plan = repos.compile(target)?; + build_plan.make_mdbook()?; + } + Commands::Info { target } => { + let recipe = repos.get_recipe(target)?; + println!("{:#?}", recipe); + } + } Ok(()) }