From 9b4c7173d6e6893d70c5c4a95c5250f733b513bd Mon Sep 17 00:00:00 2001 From: ReeseHatfield Date: Wed, 14 Oct 2026 08:37:01 -0400 Subject: [PATCH 1/5] hardcode new option instead of relying on default --- src/cmd/run.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cmd/run.rs b/src/cmd/run.rs index cc50171..e66ef28 100644 --- a/src/cmd/run.rs +++ b/src/cmd/run.rs @@ -76,6 +76,8 @@ pub fn run_with_shutdown(shutdown_flag: Arc) -> Result<(), OsedaRunE let mut child = Command::new("npx") .arg("serve") + .arg("-l") + .arg("4000") .arg("dist") .spawn() .map_err(|e| { From b15439ae8a4cdfc464160394c18ad6414374acde Mon Sep 17 00:00:00 2001 From: ReeseHatfield Date: Wed, 14 Oct 2026 08:50:25 -0400 Subject: [PATCH 2/5] parametrize port for run --- src/cmd/export.rs | 2 +- src/cmd/run.rs | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/cmd/export.rs b/src/cmd/export.rs index 1f351d7..c43f0bf 100644 --- a/src/cmd/export.rs +++ b/src/cmd/export.rs @@ -79,7 +79,7 @@ pub fn export(opts: ExportOptions) -> Result<(), Box> { let shutdown_flag = Arc::new(AtomicBool::new(false)); let run_flag = shutdown_flag.clone(); - let run_handle = std::thread::spawn(move || run::run_with_shutdown(run_flag)); + let run_handle = std::thread::spawn(move || run::run_with_shutdown(opts.port, run_flag)); // wait a moment for the localhost server to spin up std::thread::sleep(std::time::Duration::from_millis(10000)); diff --git a/src/cmd/run.rs b/src/cmd/run.rs index e66ef28..d9aec47 100644 --- a/src/cmd/run.rs +++ b/src/cmd/run.rs @@ -6,6 +6,7 @@ use std::{ }, time::Duration, }; +use clap::Args; use crate::cmd::is_cwd_oseda_project; @@ -32,6 +33,15 @@ impl std::fmt::Display for OsedaRunError { } } +/// Options struct for the run subcommand +#[derive(Args, Debug, Clone) +pub struct RunOptions { + /// Port the project runs on + #[arg(long, default_value_t = 3000)] + pub port: u16, +} + + /// Runs an Oseda project in the working directory /// /// This will: @@ -42,17 +52,17 @@ impl std::fmt::Display for OsedaRunError { /// # Returns /// * `Ok(())` if both the build and serve steps succeed /// * `Err(OsedaRunError)` if any step fails (missing vite isn't installed, or `serve` fails to start) -pub fn run() -> Result<(), OsedaRunError> { +pub fn run(opts: RunOptions) -> Result<(), OsedaRunError> { if !is_cwd_oseda_project() { return Err(OsedaRunError::NotOsedaProjectError( "oseda-config.json not found".to_string(), )); } - run_with_shutdown(Arc::new(AtomicBool::new(false))) + run_with_shutdown(opts.port, Arc::new(AtomicBool::new(false))) } -pub fn run_with_shutdown(shutdown_flag: Arc) -> Result<(), OsedaRunError> { +pub fn run_with_shutdown(port: u16, shutdown_flag: Arc) -> Result<(), OsedaRunError> { // command run failure and command status are considered different, handled accordingly match Command::new("npx").arg("vite").arg("build").status() { @@ -77,7 +87,7 @@ pub fn run_with_shutdown(shutdown_flag: Arc) -> Result<(), OsedaRunE let mut child = Command::new("npx") .arg("serve") .arg("-l") - .arg("4000") + .arg(format!("{}", port)) .arg("dist") .spawn() .map_err(|e| { From 360da605df0b49b2b43a4dc5bf35d3fb86342748 Mon Sep 17 00:00:00 2001 From: ReeseHatfield Date: Wed, 14 Oct 2026 08:51:17 -0400 Subject: [PATCH 3/5] typo --- src/cmd/run.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/run.rs b/src/cmd/run.rs index d9aec47..b081cd6 100644 --- a/src/cmd/run.rs +++ b/src/cmd/run.rs @@ -34,7 +34,7 @@ impl std::fmt::Display for OsedaRunError { } /// Options struct for the run subcommand -#[derive(Args, Debug, Clone) +#[derive(Args, Debug, Clone)] pub struct RunOptions { /// Port the project runs on #[arg(long, default_value_t = 3000)] From dbf0433cc08bca26758bcb8ecba8c69b4cef7e30 Mon Sep 17 00:00:00 2001 From: ReeseHatfield Date: Wed, 14 Oct 2026 08:59:42 -0400 Subject: [PATCH 4/5] update cli args --- src/bin/oseda.rs | 2 +- src/cmd/check.rs | 2 +- src/lib.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bin/oseda.rs b/src/bin/oseda.rs index 7bd1729..4abccd8 100644 --- a/src/bin/oseda.rs +++ b/src/bin/oseda.rs @@ -22,7 +22,7 @@ fn main() { Commands::Init(options) => { init::init(options).map(|_| println!("Successfully initialized oseda project")) } - Commands::Run => run::run() + Commands::Run(options) => run::run(options) .map(|_| println!("Successfully ran oseda project")) .map_err(|e| e.into()), Commands::Check(options) => check::check(options) diff --git a/src/cmd/check.rs b/src/cmd/check.rs index e61e604..a886f14 100644 --- a/src/cmd/check.rs +++ b/src/cmd/check.rs @@ -112,7 +112,7 @@ fn verify_project(port_num: u16) -> OsedaProjectStatus { // use shutdown hook and kill once polled as alive let run_handle = std::thread::spawn(move || { - let _ = run::run_with_shutdown(shutdown_flag_clone); + let _ = run::run_with_shutdown(port_num, shutdown_flag_clone); }); let addr = format!("http://localhost:{}", port_num); diff --git a/src/lib.rs b/src/lib.rs index b81db09..510ff4f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -28,7 +28,7 @@ pub enum Commands { /// Initialize a new Oseda project in the working directory Init(cmd::init::InitOptions), /// Run the Oseda project in the working directory - Run, + Run(cmd::run::RunOptions), /// Check the Oseda project in the working directory for common errors Check(cmd::check::CheckOptions), /// Deploy your Oseda project to github to add to oseda.net From ccff8fdc4b8e7c6f8f0709b5d3d61904db599b4a Mon Sep 17 00:00:00 2001 From: ReeseHatfield Date: Wed, 14 Oct 2026 09:59:31 -0400 Subject: [PATCH 5/5] format --- src/cmd/run.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cmd/run.rs b/src/cmd/run.rs index b081cd6..c79043e 100644 --- a/src/cmd/run.rs +++ b/src/cmd/run.rs @@ -1,3 +1,4 @@ +use clap::Args; use std::{ process::Command, sync::{ @@ -6,7 +7,6 @@ use std::{ }, time::Duration, }; -use clap::Args; use crate::cmd::is_cwd_oseda_project; @@ -41,7 +41,6 @@ pub struct RunOptions { pub port: u16, } - /// Runs an Oseda project in the working directory /// /// This will: