begun development for single file generation
All checks were successful
Test the running changes / Test (push) Successful in 40s

This commit is contained in:
2025-11-26 19:31:21 +02:00
parent 1c7504e3e0
commit 2d4f611de1
2 changed files with 26 additions and 8 deletions

View File

@@ -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<Args> 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)

View File

@@ -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(())
}