diff --git a/Cargo.toml b/Cargo.toml index 84d585e..38a0599 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ lto = "thin" [features] default = ["gui"] -gui = ["dep:tauri", "dep:tauri-plugin-log", "dep:tauri-plugin-shell"] +gui = ["dep:tauri", "dep:tauri-plugin-log", "dep:tauri-plugin-shell", "dep:tokio"] [build-dependencies] tauri-build = "2" @@ -43,7 +43,7 @@ serde_json = "1.0" tauri = { version = "2", optional = true } tauri-plugin-log = { version = "2.2.0", optional = true } tauri-plugin-shell = { version = "2", optional = true } -tokio = { version = "1.42.0", features = ["full"] } +tokio = { version = "1.42.0", features = ["full"], optional = true } [target.'cfg(windows)'.dependencies] windows = { version = "0.59.0", features = ["Win32_System_Console"] } diff --git a/src/main.rs b/src/main.rs index 7c27de2..a1eb4f4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,17 +28,17 @@ mod world_editor; use args::Args; use clap::Parser; use colored::*; +#[cfg(feature = "gui")] use fastnbt::Value; +#[cfg(feature = "gui")] use flate2::read::GzDecoder; +#[cfg(feature = "gui")] use log::{error, LevelFilter}; +#[cfg(feature = "gui")] use rfd::FileDialog; -use std::{ - env, - fs::{self, File}, - io::{Read, Write}, - panic, - path::{Path, PathBuf}, -}; +#[cfg(feature = "gui")] +use std::path::{Path, PathBuf}; +use std::{env, fs, io::Write, panic}; #[cfg(feature = "gui")] use tauri_plugin_log::{Builder as LogBuilder, Target, TargetKind}; #[cfg(target_os = "windows")] @@ -125,8 +125,8 @@ fn main() { // Write the parsed OSM data to a file for inspection if args.debug { - let mut output_file: File = - File::create("parsed_osm_data.txt").expect("Failed to create output file"); + let mut output_file: fs::File = + fs::File::create("parsed_osm_data.txt").expect("Failed to create output file"); for element in &parsed_elements { writeln!( output_file, @@ -276,6 +276,7 @@ fn gui_select_world(generate_new: bool) -> Result { } } +#[cfg(feature = "gui")] fn create_new_world(base_path: &Path) -> Result { // Generate a unique world name let mut counter: i32 = 1;