dont panic, rather return errors in main
[Mitarbeiter/Tim-Zeitz/stud-rust-base.git] / src / cli.rs
diff --git a/src/cli.rs b/src/cli.rs
new file mode 100644 (file)
index 0000000..e66421d
--- /dev/null
@@ -0,0 +1,15 @@
+//! Utility module for command line interfaces
+
+use std::{fmt, fmt::Display, error::Error};
+
+/// An error struct to wrap simple static error messages
+#[derive(Debug)]
+pub struct CliErr(pub &'static str);
+
+impl Display for CliErr {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        f.write_str(self.0)
+    }
+}
+
+impl Error for CliErr {}