summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-08-03 20:20:03 +0200
committermetamuffin <metamuffin@disroot.org>2024-08-03 20:20:03 +0200
commit16346472e77565f35e3221b3713ec217f8685b20 (patch)
tree3f5e8e6ca94547550a42a6cdbfed4d3779d58733 /src
parent89a32e683162200a10272f3b902fc1ea72b68f39 (diff)
downloadmaesch-16346472e77565f35e3221b3713ec217f8685b20.tar
maesch-16346472e77565f35e3221b3713ec217f8685b20.tar.bz2
maesch-16346472e77565f35e3221b3713ec217f8685b20.tar.zst
a
Diffstat (limited to 'src')
-rw-r--r--src/bin/cli/main.rs3
-rw-r--r--src/bin/daemon/main.rs10
-rw-r--r--src/daemon.rs14
-rw-r--r--src/main.rs29
4 files changed, 43 insertions, 13 deletions
diff --git a/src/bin/cli/main.rs b/src/bin/cli/main.rs
deleted file mode 100644
index 08cf702..0000000
--- a/src/bin/cli/main.rs
+++ /dev/null
@@ -1,3 +0,0 @@
-fn main() {
- println!("Hello, CLI!");
-}
diff --git a/src/bin/daemon/main.rs b/src/bin/daemon/main.rs
deleted file mode 100644
index 7f3d7b9..0000000
--- a/src/bin/daemon/main.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-use std::process::Command;
-use xdg::BaseDirectories;
-
-fn main() {
- println!("Hello, daemon!");
-
- // TODO db connection öffnen; idk welche db bisher
-
- // TODO für jedes netzwerk
-}
diff --git a/src/daemon.rs b/src/daemon.rs
new file mode 100644
index 0000000..c88912f
--- /dev/null
+++ b/src/daemon.rs
@@ -0,0 +1,14 @@
+use std::net::TcpListener;
+use thiserror::Error;
+
+#[derive(Debug, Error)]
+pub enum DaemonError {
+ #[error("{0}")]
+ Io(#[from] std::io::Error),
+}
+
+pub fn daemon() -> Result<(), DaemonError> {
+ let listener = TcpListener::bind("0.0.0.0")?; // TODO
+
+ Ok(())
+}
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..6bc049b
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,29 @@
+pub mod daemon;
+
+use clap::{Parser, Subcommand};
+use daemon::daemon;
+use log::error;
+
+#[derive(Parser)]
+struct Args {
+ #[clap(subcommand)]
+ action: Action,
+}
+
+#[derive(Subcommand)]
+enum Action {
+ Daemon,
+}
+
+fn main() {
+ env_logger::init_from_env("LOG");
+ let args = Args::parse();
+
+ match args.action {
+ Action::Daemon => {
+ if let Err(e) = daemon() {
+ error!("fatal error: {e}");
+ }
+ }
+ }
+}