diff --git a/gravel_cli/src/config.rs b/gravel_cli/src/config.rs index 4cf0b91..ec801f3 100644 --- a/gravel_cli/src/config.rs +++ b/gravel_cli/src/config.rs @@ -10,14 +10,17 @@ use std::net::Ipv4Addr; use std::path::{Path, PathBuf}; pub enum Command { - Generate { force: bool }, + Generate { force: bool, single: bool }, Serve { addr: Ipv4Addr, port: u16 }, Init, } impl Default for Command { fn default() -> Self { - Self::Generate { force: true } + Self::Generate { + force: true, + single: false, + } } } @@ -67,10 +70,18 @@ impl TryFrom for Command { comm = Command::Init; } // `gravel` command - else if let Some(a) = value.next() { - Err(Error::CommandLineArgsParse(format!( - "Unexpected argument: `{a}`" - )))?; + for a in value { + match a.as_str() { + "-s" => { + comm = Command::Generate { + force: true, + single: true, + } + } + _ => Err(Error::CommandLineArgsParse(format!( + "Unknown argument: `{a}`" + )))?, + } } Ok(comm) diff --git a/gravel_cli/src/main.rs b/gravel_cli/src/main.rs index 6920a81..0705113 100644 --- a/gravel_cli/src/main.rs +++ b/gravel_cli/src/main.rs @@ -15,9 +15,16 @@ fn run() -> Result<(), Error> { let conf = ProgramConfig::new("gravel.toml", std::env::args())?; match conf.command { - Command::Init => todo!("project init not implemented"), + Command::Init => todo!("project init"), Command::Serve { addr, port } => serve(addr, port, conf.outdir)?, - Command::Generate { force } => generate(&conf.indir, &conf.outdir, force)?, + Command::Generate { + force, + single: false, + } => generate(&conf.indir, &conf.outdir, force)?, + Command::Generate { + force: _f, + single: true, + } => todo!("single file generation"), } Ok(()) }