Skip to content

Commit

Permalink
feat: build CLI command
Browse files Browse the repository at this point in the history
TODO:
- Serving (with and without watching; default to watching)
  • Loading branch information
emmyoh committed May 22, 2024
1 parent dbde7f2 commit 3b6747e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ required-features = ["cli"]

[dependencies]
chrono = { version = "0.4.38", features = ["serde", "unstable-locales"] }
clap = { version = "4.5.4", features = ["derive"], optional = true }
clap = { version = "4.5.4", features = ["derive", "cargo"], optional = true }
comrak = { version = "0.22.0", features = ["syntect", "shortcodes"], default-features = false }
daggy = { version = "0.8.0", features = ["stable_dag"] }
toml = "0.8.12"
Expand Down
26 changes: 26 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use ahash::AHashMap;
use clap::{arg, crate_version};
use clap::{Parser, Subcommand};
use daggy::{stable_dag::StableDag, NodeIndex};
use glob::glob;
use liquid::{object, Object};
Expand All @@ -20,9 +22,33 @@ use vox::{builds::Build, page::Page, templates::create_liquid_parser};
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;

#[derive(Parser)]
#[command(version, about, long_about = None)]
struct Cli {
#[command(subcommand)]
command: Option<Commands>,
}
#[derive(Subcommand)]
enum Commands {
Build {
#[arg(short, long, default_value_t = false)]
watch: bool,
},
Serve {
#[arg(short, long, default_value_t = true)]
watch: bool,
},
}

#[tokio::main(flavor = "multi_thread")]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
tracing_subscriber::fmt().init();
let cli = Cli::parse();
match cli.command {
Some(Commands::Build { watch }) => build(watch).await?,
Some(Commands::Serve { watch }) => {}
None => println!("Vox {}", crate_version!()),
}
Ok(())
}

Expand Down

0 comments on commit 3b6747e

Please sign in to comment.