From b7b893d55cc748e6f6dc7f48b2abac912a0e72e7 Mon Sep 17 00:00:00 2001 From: Valerie Date: Fri, 12 Jul 2024 10:48:03 -0400 Subject: [PATCH] errors now print to stderr instead of stdout --- src/error.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/error.rs b/src/error.rs index 9521ec6..f8c72a5 100644 --- a/src/error.rs +++ b/src/error.rs @@ -2,7 +2,7 @@ use std::process::exit; /// no subcommand that matches user input; code 1 pub fn no_subcommand(subcommand: String) { - println!("remux: no command match for \"{subcommand}\""); + eprintln!("remux: no command match for \"{subcommand}\""); exit(1); } @@ -10,68 +10,68 @@ pub fn no_subcommand(subcommand: String) { /// target session not found; code 2 pub fn no_target>(target: S) { let target = target.into(); - println!("remux: no session \"{target}\" exists"); + eprintln!("remux: no session \"{target}\" exists"); exit(2); } /// help topic doesn't exist; code 3 pub fn no_help(topic: String) { - println!("remux: no help for \"{topic}\""); + eprintln!("remux: no help for \"{topic}\""); exit(3); } /// user provided no target; code 4 pub fn missing_target() { - println!("remux: no target provided"); + eprintln!("remux: no target provided"); exit(4); } /// refuse to attach to current session; code 4 pub fn same_session() { - println!("remux: cannot attach to same session"); + eprintln!("remux: cannot attach to same session"); exit(4); } /// a session with the target name already exists; code 4 pub fn target_exists>(target: S) { let target = target.into(); - println!("remux: session \"{target}\" already exists"); + eprintln!("remux: session \"{target}\" already exists"); exit(4); } /// non-terminal environment prevention; code 5 pub fn not_terminal() { - println!("remux: not running from a terminal"); + eprintln!("remux: not running from a terminal"); exit(5); } /// tried to nest while not in a session; code 6 pub fn not_nesting() { - println!("remux: inappropriate nesting flag (-n); not in a session"); + eprintln!("remux: inappropriate nesting flag (-n); not in a session"); exit(6); } /// operation requires nesting flag; code 6 pub fn prevent_nest() { - println!("remux: the nesting flag (-n) is required for nesting operation"); + eprintln!("remux: the nesting flag (-n) is required for nesting operation"); exit(6); } /// operation conflicts with nesting flag; code 6 pub fn conflict_nest(reason: Option<&'static str>) { - if let Some(reason) = reason { println!("remux: inappropriate nesting flag (-n): {reason}"); } - else { println!("remux: nesting flag (-n) is inappropriate for this operation."); } + if let Some(reason) = reason { eprintln!("remux: inappropriate nesting flag (-n): {reason}"); } + else { eprintln!("remux: nesting flag (-n) is inappropriate for this operation."); } exit(6); } /// tried to run a session command outside a session; code 7 pub fn not_in_session(cmd: &'static str) { - println!("remux: '{cmd}' must be run from within a session"); + eprintln!("remux: '{cmd}' must be run from within a session"); exit(7); }