begun development for single file generation
All checks were successful
Test the running changes / Test (push) Successful in 40s
All checks were successful
Test the running changes / Test (push) Successful in 40s
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user