Rust library to generate static websites
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

build command (#6)

* build command

* Implement build command

authored by

Erika and committed by
GitHub
4feee60a ddcff780

+33 -14
+28
crates/cli/src/build.rs
··· 1 + use std::process::{Command, Stdio}; 2 + 3 + use tracing::{debug, error}; 4 + 5 + pub fn start_build() { 6 + match Command::new("cargo") 7 + .arg("run") 8 + .stdout(Stdio::inherit()) 9 + .stderr(Stdio::inherit()) 10 + .spawn() 11 + { 12 + Ok(mut child) => match child.wait() { 13 + Ok(exit_code) => { 14 + if exit_code.success() { 15 + debug!(name: "build", "Build succeeded"); 16 + } else { 17 + error!(name: "build", "Build failed"); 18 + } 19 + } 20 + Err(err) => { 21 + error!(name: "build", "Failed to build project: {:?}", err); 22 + } 23 + }, 24 + Err(err) => { 25 + error!(name: "build", "Failed to spawn cargo: {:?}", err); 26 + } 27 + } 28 + }
+4 -10
crates/cli/src/main.rs
··· 1 + mod build; 1 2 mod dev; 2 - mod logging; 3 3 mod preview; 4 4 5 + mod logging; 6 + 5 7 use clap::{Parser, Subcommand}; 6 - use colored::Colorize; 7 8 use dev::coordinate_dev_env; 8 9 use logging::init_logging; 9 10 use preview::start_preview_web_server; 10 - use std::fmt::{self}; 11 11 use std::path::{Path, PathBuf}; 12 - use tracing::{Event, Subscriber}; 13 - use tracing_subscriber::fmt::format; 14 - use tracing_subscriber::fmt::{format::FormatFields, FmtContext}; 15 - use tracing_subscriber::registry::LookupSpan; 16 - use tracing_subscriber::util::SubscriberInitExt; 17 - use tracing_subscriber::{fmt::FormatEvent, layer::SubscriberExt}; 18 12 19 13 #[derive(Parser)] 20 14 #[command(author, version, about, long_about = None)] ··· 43 37 // matches just as you would the top level cmd 44 38 match &cli.command { 45 39 Commands::Build {} => { 46 - todo!(); 40 + build::start_build(); 47 41 } 48 42 Commands::Preview {} => { 49 43 // TODO: Dist path is hardcoded for now. Ideally, Maudit should output some kind of metadata file that can be read by the CLI.
+1 -4
crates/framework/src/logging.rs
··· 42 42 buf, 43 43 "{} {} {}", 44 44 chrono::Local::now().format("%H:%M:%S").to_string().dimmed(), 45 - format!("[{}]", record.target()) 46 - .to_string() 47 - .to_ascii_lowercase() 48 - .bright_yellow(), 45 + record.target().to_ascii_lowercase().bold().bright_yellow(), 49 46 record.args() 50 47 ) 51 48 })