Page MenuHomePhorge

mod.rs
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None
pub mod structs;
use crate::file::{self, Exists};
use crate::helpers;
use colored::Colorize;
use macros_rs::{crashln, string};
use std::fs;
use structs::{Config, Daemon, Runner};
pub fn read() -> Config {
match home::home_dir() {
Some(path) => {
let path = path.display();
let config_path = format!("{path}/.pmc/config.toml");
if !Exists::file(config_path.clone()).unwrap() {
let config = Config {
runner: Runner {
shell: string!("bash"),
args: vec![string!("-c")],
node: string!("node"),
log_path: format!("{path}/.pmc/logs"),
},
daemon: Daemon {
restarts: 10,
interval: 1000,
kind: string!("default"),
},
};
let contents = match toml::to_string(&config) {
Ok(contents) => contents,
Err(err) => crashln!("{} Cannot parse config.\n{}", *helpers::FAIL, string!(err).white()),
};
if let Err(err) = fs::write(&config_path, contents) {
crashln!("{} Error writing config.\n{}", *helpers::FAIL, string!(err).white())
}
log::info!("created config file");
}
file::read(config_path)
}
None => crashln!("{} Impossible to get your home directory", *helpers::FAIL),
}
}

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 16, 10:01 AM (20 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
484935
Default Alt Text
mod.rs (1 KB)

Event Timeline