summaryrefslogtreecommitdiff
path: root/rola-cli/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rola-cli/src/lib.rs')
-rw-r--r--rola-cli/src/lib.rs21
1 files changed, 19 insertions, 2 deletions
diff --git a/rola-cli/src/lib.rs b/rola-cli/src/lib.rs
index b3587e2..b472169 100644
--- a/rola-cli/src/lib.rs
+++ b/rola-cli/src/lib.rs
@@ -1,6 +1,9 @@
use std::process::exit;
-use mingling::macros::{gen_program, help};
+use mingling::{
+ macros::{gen_program, help, r_println, renderer},
+ res::ResExitCode,
+};
pub mod output;
pub mod res;
@@ -14,8 +17,10 @@ use error::*;
use crate::output::display::markdown;
+pub const EC_COMMAND_NOT_FOUND: i32 = 1000;
+
#[help]
-fn handle_error_dispatch_not_found(_err: ErrorDispatcherNotFound) {
+fn help_global(_err: ErrorDispatcherNotFound) {
let help = locale::helps::Basic::help().trim();
// Print directly to stderr and exit with code 0
@@ -23,6 +28,18 @@ fn handle_error_dispatch_not_found(_err: ErrorDispatcherNotFound) {
exit(0)
}
+#[renderer]
+fn render_error_dispatch_not_found(err: ErrorDispatcherNotFound, ec: &mut ResExitCode) {
+ if !err.inner.is_empty() {
+ let cmd_str = err.inner.join(" ");
+ r_println!(
+ "{}",
+ markdown(locale::errors::Common::command_not_found(cmd_str).trim())
+ );
+ ec.exit_code = EC_COMMAND_NOT_FOUND;
+ }
+}
+
gen_program!();
pub mod locale {