diff options
| author | Ellie Huxtable <ellie@elliehuxtable.com> | 2026-03-19 17:46:46 -0700 |
|---|---|---|
| committer | Ellie Huxtable <ellie@elliehuxtable.com> | 2026-03-20 04:58:30 +0000 |
| commit | 8011bbeb69ca03b48b990ce2edb20a0f2973f83d (patch) | |
| tree | a90a6cb518435ad8037416c2c376e9ad5825bb9a | |
| parent | fix: Clarify what data is sent when using Atuin AI during setup (only OS and ... (diff) | |
| download | atuin-8011bbeb69ca03b48b990ce2edb20a0f2973f83d.zip | |
feat: allow setting kv values from stdin
| -rw-r--r-- | crates/atuin/src/command/client/kv.rs | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/crates/atuin/src/command/client/kv.rs b/crates/atuin/src/command/client/kv.rs index de487b89..2736c7a6 100644 --- a/crates/atuin/src/command/client/kv.rs +++ b/crates/atuin/src/command/client/kv.rs @@ -1,3 +1,5 @@ +use std::io::{self, Read}; + use clap::Subcommand; use eyre::{Context, Result, eyre}; @@ -13,8 +15,8 @@ pub enum Cmd { #[arg(long, short)] key: String, - /// Value to store - value: String, + /// Value to store (reads from stdin if not provided) + value: Option<String>, /// Namespace for the key-value pair #[arg(long, short, default_value = "default")] @@ -80,7 +82,17 @@ impl Cmd { return Err(eyre!("namespace cannot be empty")); } - kv_store.set(namespace, key, value).await + let value = if let Some(v) = value { + v.clone() + } else { + let mut buf = String::new(); + io::stdin() + .read_to_string(&mut buf) + .context("failed to read value from stdin")?; + buf + }; + + kv_store.set(namespace, key, &value).await } Self::Delete { keys, namespace } => kv_store.delete(namespace, keys).await, |
