From cffee4c680a07a5bda931fd19936e1ec17384724 Mon Sep 17 00:00:00 2001 From: WilliamRagstad Date: Tue, 2 Apr 2024 22:33:33 +0200 Subject: [PATCH] Add optional project directory argument --- src/main.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0897c6b..4b808f1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,8 @@ mod file; mod reporting; mod runner; +use std::path::PathBuf; + use clap::{Arg, ArgAction, Command}; use colored::*; use reporting::error::error; @@ -23,6 +25,11 @@ fn cli() -> Command { .subcommand( Command::new("run") .about("Run the project web server") + .arg( + Arg::new("project") + .help("The project directory, default: current directory") + .required(false), + ) .arg( Arg::new("production") .short('p') @@ -117,8 +124,12 @@ fn main() { } else { WXMode::Dev(parse_debug_level(matches)) }; - let dir = std::env::current_dir().unwrap(); - runner::run(&dir, mode); + let project = if let Some(project) = matches.get_one::("project") { + PathBuf::from(project) + } else { + std::env::current_dir().unwrap() + }; + runner::run(&project, mode); } else if let Some(_matches) = matches.subcommand_matches("test") { todo!("Test command not implemented."); } else {