Make UI default, and remove CLI version (#83)

This commit is contained in:
Philip Kristoffersen
2022-04-15 13:54:01 +02:00
committed by GitHub
parent fcc3a4abc3
commit aa05de9865
7 changed files with 40 additions and 100 deletions
+1 -24
View File
@@ -11,38 +11,15 @@ mod steam;
mod steamgriddb;
mod sync;
mod uplay;
#[cfg(feature = "ui")]
mod ui;
use std::error::Error;
#[cfg(not(feature = "ui"))]
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let settings = settings::Settings::new()?;
if settings.steam.stop_steam{
crate::steam::ensure_steam_stopped();
}
settings::Settings::write_config_if_missing();
let usersinfo = sync::run_sync(&settings,&mut None).unwrap();
sync::download_images(&settings,&usersinfo,&mut None).await;
if settings.steam.start_steam{
crate::steam::ensure_steam_started(&settings.steam);
}
Ok(())
}
#[cfg(feature = "ui")]
fn main() -> Result<(), Box<dyn Error>> {
let mut args = std::env::args();
if args.len() > 1 && args.nth(1).unwrap_or_default() == "--no-ui" {
ui::run_sync();
Ok(())
}else{
ui::run_ui()
}
}
}
-14
View File
@@ -54,20 +54,6 @@ impl Settings {
result
}
pub fn write_config_if_missing() {
let config_path = std::path::Path::new("config.toml");
if !config_path.exists() {
let worked = std::fs::write(config_path, include_str!("defaultconfig.toml"));
match worked {
Ok(_) => println!("Create configuration file at {:?}", &config_path),
Err(err) => println!(
"Could not create configuration file at {:?}, reason: {:?}",
&config_path, err
),
}
}
}
}
fn sanitize_auth_key(result: &mut Result<Settings, ConfigError>) {
+2 -2
View File
@@ -41,7 +41,7 @@ impl MyEguiApp {
}
}
pub fn run_sync(&mut self) {
let (sender,mut reciever ) = watch::channel(SyncProgress::NotStarted);
let (sender,reciever ) = watch::channel(SyncProgress::NotStarted);
let settings = self.settings.clone();
if settings.steam.stop_steam{
crate::steam::ensure_steam_stopped();
@@ -376,7 +376,7 @@ pub fn run_ui() -> Result<(), Box<dyn Error>> {
let mut native_options = eframe::NativeOptions::default();
native_options.initial_window_size = Some(egui::Vec2{
x:500.,
x:800.,
y:500.
});
native_options.icon_data = Some(get_logo_icon());