From a5ea94fd04873a203d0a5e2066ca4177c5102c93 Mon Sep 17 00:00:00 2001 From: core Date: Thu, 27 Nov 2025 20:33:55 -0500 Subject: [PATCH] feat: better err msg --- Cargo.toml | 2 +- src/wrapper.rs | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 40fc8ab202f90fda7378a181c491ba22aa060155..74af25563ad1a0e7015b925cf92f244b0150d8e8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "sage" version = "0.1.0" edition = "2024" -license = "GPL-3" +license = "AGPL-3.0-only" description = "A simple wrapper for `age` to add a named identity system." homepage = "https://git.srht.e3t.cc/~core/sage" repository = "https://git.srht.e3t.cc/~core/sage" diff --git a/src/wrapper.rs b/src/wrapper.rs index d48a40c222de6fee36b5d776e704b1fa91ccfdf7..d77584178e0ca0d2d38b09e9ee9a1de978740fca 100644 --- a/src/wrapper.rs +++ b/src/wrapper.rs @@ -2,7 +2,7 @@ use crate::db::Database; use crate::identity::IdKeyData; use anyhow::bail; use pico_args::Arguments; -use std::os::unix::prelude::CommandExt; +use std::io::ErrorKind; use std::path::{Path, PathBuf}; use std::process::{Command, exit}; use std::str::FromStr; @@ -187,7 +187,20 @@ pub fn wrapper(mut pargs: Arguments, db_path: &Path) -> anyhow::Result<()> { eprintln!("exec age {:?}", args); } - Err(Command::new("age").args(args).exec())?; + let mut c = match Command::new("age").args(args).spawn() { + Ok(c) => c, + Err(e) if e.kind() == ErrorKind::NotFound => { + eprintln!("{e}"); + eprintln!("is `age` installed?"); + exit(0); + } + Err(e) => { + return Err(e)?; + } + }; + + c.wait()?; + Ok(()) }