Early gui impl, basic window management
This commit is contained in:
@@ -24,4 +24,8 @@ path="src/main.rs"
|
||||
xmpd-cli={ path="../xmpd-cli" }
|
||||
xmpd-gui={ path="../xmpd-gui" }
|
||||
xmpd-manifest={ path="../xmpd-manifest" }
|
||||
clap = { workspace=true }
|
||||
clap.workspace=true
|
||||
camino.workspace = true
|
||||
anyhow.workspace = true
|
||||
log.workspace = true
|
||||
env_logger.workspace = true
|
||||
|
||||
18
xmpd-core/src/cli.rs
Normal file
18
xmpd-core/src/cli.rs
Normal 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
17
xmpd-core/src/logger.rs
Normal 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();
|
||||
}
|
||||
@@ -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(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user