aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorevuez <julien@mulga.net>2024-04-03 22:43:16 +0200
committerevuez <julien@mulga.net>2024-04-03 22:43:16 +0200
commit43e1a12b5bce11b4a28a53acca243e35c2be6d3e (patch)
tree07d64823718bfee063ab7b3d5721ac1e950ae17c /src/main.rs
downloadcarton-43e1a12b5bce11b4a28a53acca243e35c2be6d3e.tar.gz
Initial commit
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..3d0eee5
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,65 @@
+#![deny(clippy::all)]
+#![warn(clippy::pedantic)]
+#![allow(clippy::module_name_repetitions)]
+#![feature(file_create_new)]
+#![feature(map_try_insert)]
+#![feature(result_option_inspect)]
+
+mod client;
+mod common;
+mod index;
+mod server;
+
+// use fs::FileSystem;
+// use index::Index;
+use client::fs::FileSystem;
+use serde::{Deserialize, Serialize};
+use server::Server;
+use std::env;
+
+const CONFIG: &str = "carton.toml";
+
+#[derive(Serialize, Deserialize)]
+struct Config {
+ server: server::Config,
+ client: client::Config,
+}
+
+fn main() {
+ let mut logger = env_logger::Builder::from_default_env();
+ logger.filter(None, log::LevelFilter::Debug).init();
+
+ // Config
+ let config: Config = toml::from_str(
+ &std::fs::read_to_string(CONFIG).expect("Missing config file at {CONFIG:?}"),
+ )
+ .expect("Invalid config file at {CONFIG:?}");
+
+ // Args
+ let args: Vec<String> = env::args().collect();
+
+ if args.len() < 2 {
+ println!("Missing command for carton.");
+ return;
+ }
+
+ match args[1].as_str() {
+ // "index-scan" => cmd_index_scan(&args[2..]),
+ // "reindex" => cmd_index_scan(&args[2..]),
+ "fs-mount" => cmd_fs_mount(config, &args[2..]),
+ _ => todo!(),
+ }
+}
+
+// fn cmd_index_scan(args: &[String]) {
+// index::spawn_scan(Path::new(ROOT));
+// }
+
+fn cmd_fs_mount(config: Config, _args: &[String]) {
+ let server = Server::new(&config.server).expect("Couldn't initialize server.");
+
+ // let index = Index::new(Path::new(ROOT)).unwrap();
+
+ let fs = FileSystem::new(server);
+ fs.mount(&config.client.fs.mountpoint).unwrap();
+}