Skip to content

Commit

Permalink
Add optional project directory argument
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamRagstad committed Apr 2, 2024
1 parent 1f678a9 commit cffee4c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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')
Expand Down Expand Up @@ -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::<String>("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 {
Expand Down

0 comments on commit cffee4c

Please sign in to comment.