summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Hurst <ark@mansus.space>2025-12-28 17:54:49 +0100
committerJulian Hurst <ark@mansus.space>2025-12-28 17:54:49 +0100
commit1f1f0177f3a28837f2a25f4a240b80469442374c (patch)
treef077a5d34cc8ed6b3b6a5a47f5f6efc4e658fd7f
parent4633848d09ae158e8b410551660c71afddc91da1 (diff)
downloadimp-1f1f0177f3a28837f2a25f4a240b80469442374c.tar.gz
Support reading from stdin instead of decrypting with gpgHEADmaster
-rw-r--r--imp.ha27
1 files 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);