From 8011bbeb69ca03b48b990ce2edb20a0f2973f83d Mon Sep 17 00:00:00 2001 From: Ellie Huxtable Date: Thu, 19 Mar 2026 17:46:46 -0700 Subject: feat: allow setting kv values from stdin --- crates/atuin/src/command/client/kv.rs | 18 +++++++++++++++--- 1 file 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, /// 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, -- cgit v1.3.1