diff options
Diffstat (limited to 'src/cli/workspace.rs')
| -rw-r--r-- | src/cli/workspace.rs | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/cli/workspace.rs b/src/cli/workspace.rs index ae29792c..8149d55d 100644 --- a/src/cli/workspace.rs +++ b/src/cli/workspace.rs @@ -1,3 +1,5 @@ +use std::collections::HashMap; + use crate::api::schema::{ EmptyParams, Method, Request, WorkspaceCreateParams, WorkspaceRenameParams, WorkspaceTarget, }; @@ -42,6 +44,7 @@ fn workspace_create(args: &[String]) -> std::io::Result<i32> { let mut cwd = None; let mut focus = false; let mut label = None; + let mut env = HashMap::new(); let mut index = 0; while index < args.len() { @@ -70,6 +73,21 @@ fn workspace_create(args: &[String]) -> std::io::Result<i32> { focus = false; index += 1; } + "--env" => { + let Some(value) = args.get(index + 1) else { + eprintln!("missing value for --env"); + return Ok(2); + }; + let (key, value) = match super::parse_env_assignment(value) { + Ok(pair) => pair, + Err(err) => { + eprintln!("{err}"); + return Ok(2); + } + }; + env.insert(key, value); + index += 2; + } other => { eprintln!("unknown option: {other}"); return Ok(2); @@ -79,7 +97,12 @@ fn workspace_create(args: &[String]) -> std::io::Result<i32> { super::print_response(&super::send_request(&Request { id: "cli:workspace:create".into(), - method: Method::WorkspaceCreate(WorkspaceCreateParams { cwd, focus, label }), + method: Method::WorkspaceCreate(WorkspaceCreateParams { + cwd, + focus, + label, + env, + }), })?) } @@ -155,7 +178,7 @@ fn workspace_close(args: &[String]) -> std::io::Result<i32> { fn print_workspace_help() { eprintln!("herdr workspace commands:"); eprintln!(" herdr workspace list"); - eprintln!(" herdr workspace create [--cwd PATH] [--label TEXT] [--focus] [--no-focus]"); + eprintln!(" herdr workspace create [--cwd PATH] [--label TEXT] [--env KEY=VALUE] [--focus] [--no-focus]"); eprintln!(" herdr workspace get <workspace_id>"); eprintln!(" herdr workspace focus <workspace_id>"); eprintln!(" herdr workspace rename <workspace_id> <label>"); |
