summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..a4f8963
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,27 @@
+mod device;
+mod config;
+
+use std::{env, process, str};
+
+const PROGRAM: &str = "z2m-utils";
+
+fn main() {
+ let config = config::get();
+
+ let mut args = env::args_os();
+ // Can't fail (it's a bug for sure)
+ let argv0 = args.next().unwrap();
+ let argv0 = argv0.to_str().unwrap_or(PROGRAM);
+ let Some(command) = args.next() else {
+ eprintln!("Usage: {argv0} <command> [args...]");
+ process::exit(1);
+ };
+
+ match command.to_str() {
+ Some("device") => device::main(argv0, config, args),
+ _ => {
+ eprintln!("{argv0}: error: Unknown command: {command:?}");
+ process::exit(1);
+ }
+ }
+}