diff options
| author | Aram Drevekenin <aram@poor.dev> | 2026-03-09 16:02:43 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-09 16:02:43 +0100 |
| commit | 780784ab761425386df7a16d06337b31b0479847 (patch) | |
| tree | 381914054e350e8e4427fb3dc8477a82b30c2f4e /src | |
| parent | Update CHANGELOG.md (diff) | |
| download | sl0ppij-780784ab761425386df7a16d06337b31b0479847.tar.gz sl0ppij-780784ab761425386df7a16d06337b31b0479847.tar.xz sl0ppij-780784ab761425386df7a16d06337b31b0479847.zip | |
allow specifying ip/port with the zellij web --status cli (#4825)
* allow specifying ip/port with the zellij web --status cli
* add pr
Diffstat (limited to '')
| -rw-r--r-- | src/main.rs | 8 | ||||
| -rw-r--r-- | src/tests/cli.rs | 53 |
2 files changed, 60 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index ddca0f27..0ca0daf1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -304,8 +304,14 @@ fn main() { }, } } else if web_opts.status { - let config_options = commands::get_config_options_from_cli_args(&opts) + let mut config_options = commands::get_config_options_from_cli_args(&opts) .expect("Can't find config options"); + if let Some(ip) = web_opts.ip { + config_options.web_server_ip = Some(ip); + } + if let Some(port) = web_opts.port { + config_options.web_server_port = Some(port); + } let web_server_base_url = web_server_base_url_from_config(config_options); match commands::web_server_status(&web_server_base_url, web_opts.timeout) { Ok(version) => { diff --git a/src/tests/cli.rs b/src/tests/cli.rs index 95864d56..12d8ca6d 100644 --- a/src/tests/cli.rs +++ b/src/tests/cli.rs @@ -1,3 +1,5 @@ +use std::net::{IpAddr, Ipv4Addr}; + use clap::Parser; use zellij_utils::cli::{CliArgs, Command}; @@ -67,3 +69,54 @@ fn web_cli_status_with_stop_fails() { let args = CliArgs::try_parse_from(["zellij", "web", "--status", "--stop"]); assert!(args.is_err()); } + +#[test] +fn web_cli_status_with_ip_works() { + let args = CliArgs::try_parse_from(["zellij", "web", "--status", "--ip", "127.0.0.1"]); + assert!(args.is_ok()); + if let Ok(CliArgs { + command: Some(Command::Web(web)), + .. + }) = args + { + assert!(web.status); + assert_eq!(web.ip, Some(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)))); + } else { + panic!("Expected Web command"); + } +} + +#[test] +fn web_cli_status_with_port_works() { + let args = CliArgs::try_parse_from(["zellij", "web", "--status", "--port", "9000"]); + assert!(args.is_ok()); + if let Ok(CliArgs { + command: Some(Command::Web(web)), + .. + }) = args + { + assert!(web.status); + assert_eq!(web.port, Some(9000)); + } else { + panic!("Expected Web command"); + } +} + +#[test] +fn web_cli_status_with_ip_and_port_works() { + let args = CliArgs::try_parse_from([ + "zellij", "web", "--status", "--ip", "0.0.0.0", "--port", "9000", + ]); + assert!(args.is_ok()); + if let Ok(CliArgs { + command: Some(Command::Web(web)), + .. + }) = args + { + assert!(web.status); + assert_eq!(web.ip, Some(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))); + assert_eq!(web.port, Some(9000)); + } else { + panic!("Expected Web command"); + } +} |
