about summary refs log tree commit diff stats
path: root/pkgs
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/by-name/no/notify-run/src/main.rs23
1 files changed, 20 insertions, 3 deletions
diff --git a/pkgs/by-name/no/notify-run/src/main.rs b/pkgs/by-name/no/notify-run/src/main.rs
index de625627..a6a0165a 100644
--- a/pkgs/by-name/no/notify-run/src/main.rs
+++ b/pkgs/by-name/no/notify-run/src/main.rs
@@ -8,7 +8,7 @@
 // You should have received a copy of the License along with this program.
 // If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
 
-use std::{env::args, process::Command};
+use std::{env::args, path::PathBuf, process::Command};
 
 use anyhow::{Context, Result};
 
@@ -40,9 +40,26 @@ fn main() -> Result<()> {
             )
         })?;
     } else {
-        print!("{}", String::from_utf8_lossy(&output.stdout));
-        eprint!("{}", String::from_utf8_lossy(&output.stderr));
+        let name = PathBuf::from(&args[0])
+            .file_name()
+            .expect("this to be a command, and thus have a file_name")
+            .to_string_lossy()
+            .to_string();
+
+        print!("{}", append_name(&name, &output.stdout));
+        eprint!("{}", append_name(&name, &output.stderr));
     }
 
     Ok(())
 }
+
+fn append_name(name: &str, base: &[u8]) -> String {
+    let base = String::from_utf8_lossy(base).to_string();
+
+    let mut output = String::new();
+    for line in base.lines() {
+        output.push_str(format!("{name}> {line}\n").as_str());
+    }
+
+    output
+}