forked from InfoshockTech/xcrab
Create separate executable
This commit is contained in:
parent
7d622540cf
commit
15812e17bf
|
@ -10,3 +10,7 @@ toml = "0.5.9"
|
|||
serde = { version = "1.0.137", features = ["derive"]}
|
||||
lazy_static = "1.4.0"
|
||||
slotmap = "1.0.6"
|
||||
|
||||
[[bin]]
|
||||
name = "xcrab-msg"
|
||||
path = "src/msg/main.rs"
|
||||
|
|
24
src/msg/config.rs
Normal file
24
src/msg/config.rs
Normal file
|
@ -0,0 +1,24 @@
|
|||
use crate::Result;
|
||||
use serde::Deserialize;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
// Dummy struct for deserializing the message config - we're using the same file for both binaries
|
||||
pub struct XcrabConfig {
|
||||
pub msg: Option<XcrabMsgConfig>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
pub struct XcrabMsgConfig {
|
||||
socket_path: PathBuf,
|
||||
}
|
||||
|
||||
pub fn load_file() -> Result<XcrabConfig> {
|
||||
let home_dir = std::env::var("HOME")?;
|
||||
|
||||
let contents = std::fs::read_to_string(format!("{}/.config/xcrab/config.toml", home_dir))?;
|
||||
|
||||
let config: XcrabConfig = toml::from_str(&contents)?;
|
||||
|
||||
Ok(config)
|
||||
}
|
10
src/msg/main.rs
Normal file
10
src/msg/main.rs
Normal file
|
@ -0,0 +1,10 @@
|
|||
mod config;
|
||||
|
||||
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
let conf = config::load_file()?;
|
||||
|
||||
Ok(())
|
||||
}
|
Loading…
Reference in a new issue