diff options
| author | Ellie Huxtable <ellie@elliehuxtable.com> | 2026-03-19 17:48:04 -0700 |
|---|---|---|
| committer | Ellie Huxtable <ellie@elliehuxtable.com> | 2026-03-20 04:58:30 +0000 |
| commit | a9a42e3fa012ebf9dc0b56a6cc97a10eb8999dcd (patch) | |
| tree | 61448fa20e30a1751f7efd74d3c450d6c45ab7a0 /crates | |
| parent | feat: allow setting kv values from stdin (diff) | |
| download | atuin-a9a42e3fa012ebf9dc0b56a6cc97a10eb8999dcd.zip | |
feat: error if value not provided and no stdin
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/atuin/src/command/client/kv.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/crates/atuin/src/command/client/kv.rs b/crates/atuin/src/command/client/kv.rs index 2736c7a6..88e3edeb 100644 --- a/crates/atuin/src/command/client/kv.rs +++ b/crates/atuin/src/command/client/kv.rs @@ -1,4 +1,4 @@ -use std::io::{self, Read}; +use std::io::{self, IsTerminal, Read}; use clap::Subcommand; use eyre::{Context, Result, eyre}; @@ -84,12 +84,16 @@ impl Cmd { let value = if let Some(v) = value { v.clone() - } else { + } else if !io::stdin().is_terminal() { let mut buf = String::new(); io::stdin() .read_to_string(&mut buf) .context("failed to read value from stdin")?; buf + } else { + return Err(eyre!( + "no value provided. Pass as an argument or pipe via stdin" + )); }; kv_store.set(namespace, key, &value).await |
