From 1f1f0177f3a28837f2a25f4a240b80469442374c Mon Sep 17 00:00:00 2001 From: Julian Hurst Date: Sun, 28 Dec 2025 17:54:49 +0100 Subject: Support reading from stdin instead of decrypting with gpg --- imp.ha | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/imp.ha b/imp.ha index 73cdad5..c7fdfb9 100644 --- a/imp.ha +++ b/imp.ha @@ -104,15 +104,24 @@ export fn main() void = { fmt::fatal("No file specified and the IMP_FILE environment variable isn't set"); }; - let ini_data = match (decrypt(file)) { - case let s: []u8 => - yield s; - case let e: os::exec::error => - fmt::fatal(os::exec::strerror(e)); - case let e: io::error => - fmt::fatal(io::strerror(e)); - case nomem => - fmt::fatal("Insufficient memory"); + let ini_data = if (file == "-") { + yield match (io::drain(os::stdin)) { + case let e: io::error => + fmt::fatal(io::strerror(e)); + case let u: []u8 => + yield u; + }; + } else { + yield match (decrypt(file)) { + case let s: []u8 => + yield s; + case let e: os::exec::error => + fmt::fatal(os::exec::strerror(e)); + case let e: io::error => + fmt::fatal(io::strerror(e)); + case nomem => + fmt::fatal("Insufficient memory"); + }; }; defer free(ini_data); -- cgit v1.2.3