Early gui impl, basic window management

This commit is contained in:
2024-11-07 15:42:34 +02:00
parent a00486eeaf
commit 4dcd36c3d8
14 changed files with 3905 additions and 24 deletions

18
xmpd-core/src/cli.rs Normal file
View File

@@ -0,0 +1,18 @@
use std::path::{Path, PathBuf};
#[derive(Debug, clap::Parser)]
pub struct CliArgs {
/// Manifest path
#[arg(long, short)]
manifest: Option<camino::Utf8PathBuf>,
/// Debug mode
#[arg(long, short)]
pub debug: bool,
}
impl CliArgs {
pub fn manifest_path(&self) -> Option<PathBuf> {
Some(self.manifest.clone()?.into_std_path_buf())
}
}

17
xmpd-core/src/logger.rs Normal file
View File

@@ -0,0 +1,17 @@
use log::LevelFilter;
use crate::cli::CliArgs;
pub fn init(cliargs: &CliArgs) {
let level = if cliargs.debug { LevelFilter::Debug } else { LevelFilter::Info };
env_logger::builder()
.format_timestamp(None)
.filter(Some("xmpd_core"), level)
.filter(Some("xmpd_cli"), level)
.filter(Some("xmpd_gui"), level)
.filter(Some("xmpd_manifest"), level)
.filter(Some("xmpd_dl"), level)
.init();
}

View File

@@ -1,9 +1,21 @@
use std::path::{Path, PathBuf};
fn main() {
let args = std::env::args();
if args.len() > 1 {
// gui
} else {
// cli
}
use clap::Parser;
mod cli;
mod logger;
type Result<T> = anyhow::Result<T>;
fn main() -> Result<()> {
let cliargs = cli::CliArgs::parse();
logger::init(&cliargs);
let manifest_path;
if let Some(mp) = cliargs.manifest_path() {
manifest_path = mp;
} else {
manifest_path = PathBuf::from("manifest.json");
};
xmpd_gui::start(manifest_path)?;
Ok(())
}