From b0ca2fd9329e7950dd0651f6f3a59a4391ad783d Mon Sep 17 00:00:00 2001 From: Elizabeth Engelman <4752801+elizabethengelman@users.noreply.github.com> Date: Wed, 10 Jan 2024 16:41:44 -0500 Subject: [PATCH] Add optional args for protocol-version and limits --- cmd/soroban-cli/src/commands/network/start.rs | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/cmd/soroban-cli/src/commands/network/start.rs b/cmd/soroban-cli/src/commands/network/start.rs index 17146f374b..0205ae2876 100644 --- a/cmd/soroban-cli/src/commands/network/start.rs +++ b/cmd/soroban-cli/src/commands/network/start.rs @@ -36,6 +36,14 @@ pub struct Cmd { #[arg(short = 'r', long)] pub disable_soroban_rpc: bool, + // option argument to specify the protocol version for the local network only + #[arg(short = 'p', long)] + pub protocol_version: Option, + + // option argument to specify the limits for the local network only + #[arg(short = 'l', long)] + pub limit: Option, + // optional arguments to pass to the docker run command #[arg(last = true, id = "DOCKER_RUN_ARGS")] pub slop: Vec, @@ -71,16 +79,20 @@ fn build_docker_command(cmd: &Cmd) -> String { let image = get_image_name(cmd); let container_name = get_container_name(cmd); let port_mapping = get_port_mapping(cmd); + let protocol_version = get_protocol_version_arg(cmd); + let limits = get_limits_arg(cmd); let docker_command = format!( - "docker run --rm {slop} {port} {container_name} {image} --{network} {enable_soroban_rpc}", + "docker run --rm {slop} {port} {container_name} {image} --{network} {enable_soroban_rpc} {protocol_version} {limits}", port = format_args!("-p {port_mapping}"), container_name = format_args!("--name {container_name}"), image = image, network = cmd.network, slop = cmd.slop.join(" "), enable_soroban_rpc = if cmd.disable_soroban_rpc { "" } else { "--enable-soroban-rpc" }, + protocol_version = protocol_version, + limits = limits, ); docker_command @@ -119,3 +131,21 @@ fn get_port_mapping(cmd: &Cmd) -> String { format!("{FROM_PORT}:{TO_PORT}") } } + +fn get_protocol_version_arg(cmd: &Cmd) -> String { + if cmd.network == "local" && cmd.protocol_version.is_some() { + let version = cmd.protocol_version.as_ref().unwrap(); + format!("--protocol-version {version}") + } else { + "".to_string() + } +} + +fn get_limits_arg(cmd: &Cmd) -> String { + if cmd.network == "local" && cmd.limit.is_some() { + let limit = cmd.limit.as_ref().unwrap(); + format!("--limits {limit}") + } else { + "".to_string() + } +}