Downloading prototype works
This commit is contained in:
@@ -21,7 +21,7 @@ name="xmpd"
|
||||
path="src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
xmpd-cli.path="../xmpd-cli"
|
||||
xmpd-cliargs.path="../xmpd-cliargs"
|
||||
xmpd-gui.path="../xmpd-gui"
|
||||
xmpd-manifest.path="../xmpd-manifest"
|
||||
xmpd-settings.path = "../xmpd-settings"
|
||||
@@ -30,4 +30,3 @@ camino.workspace = true
|
||||
anyhow.workspace = true
|
||||
log.workspace = true
|
||||
env_logger.workspace = true
|
||||
dirs.workspace = true
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
use std::{path::PathBuf, str::FromStr};
|
||||
|
||||
|
||||
#[derive(Debug, clap::Parser)]
|
||||
pub struct CliArgs {
|
||||
/// Manifest path
|
||||
#[arg(long, short, default_value_t=get_default_manifest_path())]
|
||||
manifest: camino::Utf8PathBuf,
|
||||
/// settings file path
|
||||
#[arg(long, short, default_value_t=get_default_settings_path())]
|
||||
settings: camino::Utf8PathBuf,
|
||||
/// Cache dir path
|
||||
#[arg(long, short, default_value_t=get_default_cache_path())]
|
||||
cache: camino::Utf8PathBuf,
|
||||
/// Debug mode
|
||||
#[arg(long, short)]
|
||||
pub debug: bool,
|
||||
}
|
||||
|
||||
impl CliArgs {
|
||||
pub fn manifest_path(&self) -> PathBuf {
|
||||
self.manifest.clone().into_std_path_buf()
|
||||
}
|
||||
pub fn settings_path(&self) -> PathBuf {
|
||||
self.settings.clone().into_std_path_buf()
|
||||
}
|
||||
pub fn cache_path(&self) -> PathBuf {
|
||||
self.cache.clone().into_std_path_buf()
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(irrefutable_let_patterns)] // Broken?
|
||||
fn get_default_settings_path() -> camino::Utf8PathBuf {
|
||||
if let Ok(p) = std::env::var("XMPD_SETTINGS_PATH") {
|
||||
if let Ok(p) = camino::Utf8PathBuf::from_str(&p) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(mut p) = dirs::config_dir() {
|
||||
p.push("xmpd");
|
||||
p.push("config.toml");
|
||||
return camino::Utf8PathBuf::from_path_buf(p).expect("Invalid os path");
|
||||
}
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
#[allow(irrefutable_let_patterns)] // Broken?
|
||||
fn get_default_manifest_path() -> camino::Utf8PathBuf {
|
||||
if let Ok(p) = std::env::var("XMPD_MANIFEST_PATH") {
|
||||
if let Ok(p) = camino::Utf8PathBuf::from_str(&p) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
if let Some(mut p) = dirs::config_dir() {
|
||||
p.push("xmpd");
|
||||
p.push("manifest.json");
|
||||
return camino::Utf8PathBuf::from_path_buf(p).expect("Invalid os path");
|
||||
}
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
#[allow(irrefutable_let_patterns)] // Broken?
|
||||
fn get_default_cache_path() -> camino::Utf8PathBuf {
|
||||
if let Ok(p) = std::env::var("XMPD_CACHE_PATH") {
|
||||
if let Ok(p) = camino::Utf8PathBuf::from_str(&p) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
if let Some(mut p) = dirs::cache_dir() {
|
||||
p.push("xmpd");
|
||||
return camino::Utf8PathBuf::from_path_buf(p).expect("Invalid os path");
|
||||
}
|
||||
unreachable!()
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
use log::LevelFilter;
|
||||
|
||||
use crate::cli::CliArgs;
|
||||
|
||||
use xmpd_cliargs::CliArgs;
|
||||
|
||||
|
||||
pub fn init(cliargs: &CliArgs) {
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
use std::borrow::BorrowMut;
|
||||
|
||||
use clap::Parser;
|
||||
|
||||
mod cli;
|
||||
mod logger;
|
||||
|
||||
type Result<T> = anyhow::Result<T>;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let cliargs = cli::CliArgs::parse();
|
||||
// NOTE: Parses on first load
|
||||
let cliargs = &xmpd_cliargs::CLIARGS;
|
||||
logger::init(&cliargs);
|
||||
log::debug!("Cli: {cliargs:?}");
|
||||
log::debug!("Initialising settings");
|
||||
xmpd_settings::Settings::get()?.load(Some(cliargs.settings_path()))?;
|
||||
xmpd_gui::start(cliargs.manifest_path())?;
|
||||
log::debug!("Starting gui");
|
||||
xmpd_gui::start()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user