mirror of
https://git.alemi.dev/dashboard.git
synced 2024-11-14 19:59:18 +01:00
feat: allow to pass specific db file via argv
This commit is contained in:
parent
b91eee5e97
commit
bc8f74335e
1 changed files with 17 additions and 3 deletions
20
src/main.rs
20
src/main.rs
|
@ -6,19 +6,33 @@ use crate::app::{
|
||||||
worker::{BackgroundWorker, NativeBackgroundWorker},
|
worker::{BackgroundWorker, NativeBackgroundWorker},
|
||||||
App,
|
App,
|
||||||
};
|
};
|
||||||
|
use std::path::PathBuf;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use tracing::metadata::LevelFilter;
|
||||||
use tracing_subscriber::prelude::*;
|
use tracing_subscriber::prelude::*;
|
||||||
|
|
||||||
// When compiling natively:
|
// When compiling natively:
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
fn main() -> ! {
|
fn main() -> ! {
|
||||||
use tracing::metadata::LevelFilter;
|
|
||||||
|
|
||||||
let native_options = eframe::NativeOptions::default();
|
let native_options = eframe::NativeOptions::default();
|
||||||
|
|
||||||
let mut store_path = dirs::data_dir().unwrap_or(std::path::PathBuf::from(".")); // TODO get cwd more consistently?
|
let args: Vec<String> = std::env::args().collect();
|
||||||
|
|
||||||
|
// Set default file location
|
||||||
|
let mut store_path = dirs::data_dir().unwrap_or(PathBuf::from(".")); // TODO get cwd more consistently?
|
||||||
store_path.push("dashboard.db");
|
store_path.push("dashboard.db");
|
||||||
|
|
||||||
|
// Can be overruled from argv
|
||||||
|
for (index, arg) in args.iter().enumerate() {
|
||||||
|
if index <= 0 || arg.eq("--") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
store_path = PathBuf::from(arg.as_str());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("path: {}", store_path.to_str().unwrap());
|
||||||
|
|
||||||
let store =
|
let store =
|
||||||
Arc::new(ApplicationState::new(store_path).expect("Failed creating application state"));
|
Arc::new(ApplicationState::new(store_path).expect("Failed creating application state"));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue