aboutsummaryrefslogtreecommitdiffstats
path: root/crates/rocie-server/src/cli.rs
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-10-08 11:58:49 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-10-08 11:58:49 +0200
commit9204e472e4f714c84237bca5ebe740080a589917 (patch)
treed17f31240b24fcb2c47eec21edf6a9f512d80123 /crates/rocie-server/src/cli.rs
parentfeat(crates/rocie-server/unit-property): Init (diff)
downloadserver-9204e472e4f714c84237bca5ebe740080a589917.zip
test(crates/rocie-server/testenv/init): Automatically choose the port and wait for server start
This avoids issues regarding a race condition between server start and our start of requests and removes the requirement for specifying free ports in the test files.
Diffstat (limited to '')
-rw-r--r--crates/rocie-server/src/cli.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/crates/rocie-server/src/cli.rs b/crates/rocie-server/src/cli.rs
index b2ec214..80b4292 100644
--- a/crates/rocie-server/src/cli.rs
+++ b/crates/rocie-server/src/cli.rs
@@ -13,8 +13,16 @@ pub(crate) enum Command {
/// Serve the server.
Serve {
/// Which port to serve the server on.
- #[arg(short, long, default_value = "8080")]
- port: u16,
+ ///
+ /// Leave empty to let the OS choose a free one.
+ #[arg(short, long)]
+ port: Option<u16>,
+
+ /// Print the used port as single u16 to stdout when started.
+ ///
+ /// This can be used, to determine the used port, when the `port` was left at `None`.
+ #[arg(long)]
+ print_port: bool,
/// Which host to serve the server on.
#[arg(short = 'b', long, default_value = "127.0.0.1")]