Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor Release Fixes #75

Merged
merged 6 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions locale/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"weakaura-updates-queued": "Aktualisierung in Warteschlange. Aktualisierung im Spiel erforderlich.",
"weakauras-loaded": "{number} geladen",
"website": "Website",
"website-http": "https://getgrin.com",
"website-http": "https://grin.mw",
"welcome-to-grin-gui-description": "Bitte wähle dein Verzeichnis",
"woops": "Ups!",
"wtf": "WTF",
Expand Down Expand Up @@ -153,7 +153,7 @@
"auto-update": "Neue Updates automatisch anwenden, wenn sie verfügbar sind",
"type": "Typ",
"donate": "Unterstützen",
"donate-http": "https://www.getajour.com/donate",
"donate-http": "https://grin.mw/fund",
"close-to-tray": "Schließen in der Systemablage",
"toggle-autostart": "Grin automatisch nach der Anmeldung öffnen",
"start-closed-to-tray": "Start Grin geschlossen in System Tray",
Expand Down
4 changes: 2 additions & 2 deletions locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"weakaura-updates-queued": "Updates can now be applied in-game",
"weakauras-loaded": "{number} loaded",
"website": "Website",
"website-http": "https://getgrin.com",
"website-http": "https://grin.mw",
"welcome-to-grin-gui-description": "Please select your directory",
"woops": "Woops!",
"wtf": "WTF",
Expand Down Expand Up @@ -153,7 +153,7 @@
"auto-update": "Automatically apply new updates when available",
"type": "Type",
"donate": "Donate",
"donate-http": "https://www.getajour.com/donate",
"donate-http": "https://grin.mw/fund",
"close-to-tray": "Close to System Tray",
"toggle-autostart": "Open Grin automatically after you log in",
"start-closed-to-tray": "Start Grin closed to System Tray",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Desktop Entry]
Type=Application
Terminal=false
Exec=ajour
Name=ajour
Icon=ajour
Exec=grin-gui
Name=grin-gui
Icon=grin
Categories=Game;
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
2 changes: 1 addition & 1 deletion resources/windows/res.rc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#define IDI_ICON 0x101

IDI_ICON ICON "ajour.ico"
IDI_ICON ICON "grin.ico"
149 changes: 50 additions & 99 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,63 @@ use crate::VERSION;

use isahc::http::Uri;
use structopt::{
clap::{self, AppSettings},
StructOpt,
clap::{self, AppSettings},
StructOpt,
};

use std::env;
use std::path::PathBuf;

pub fn get_opts() -> Result<Opts, clap::Error> {
let args = env::args_os();
let args = env::args_os();

Opts::from_iter_safe(args)
Opts::from_iter_safe(args)
}

#[allow(unused_variables)]
pub fn validate_opts_or_exit(
opts_result: Result<Opts, clap::Error>,
is_cli: bool,
is_debug: bool,
opts_result: Result<Opts, clap::Error>,
is_cli: bool,
is_debug: bool,
) -> Opts {
// If an error, we need to setup the AttachConsole fix for Windows release
// so we can exit and display the error message to the user.
let is_opts_error = opts_result.is_err();
// If an error, we need to setup the AttachConsole fix for Windows release
// so we can exit and display the error message to the user.
let is_opts_error = opts_result.is_err();

// Workaround to output to console even though we compile with windows_subsystem = "windows"
// in release mode
#[cfg(target_os = "windows")]
{
if (is_cli || is_opts_error) && !is_debug {
use winapi::um::wincon::{AttachConsole, ATTACH_PARENT_PROCESS};
// Workaround to output to console even though we compile with windows_subsystem = "windows"
// in release mode
#[cfg(target_os = "windows")]
{
if (is_cli || is_opts_error) && !is_debug {
use winapi::um::wincon::{AttachConsole, ATTACH_PARENT_PROCESS};

unsafe {
AttachConsole(ATTACH_PARENT_PROCESS);
}
}
}
unsafe {
AttachConsole(ATTACH_PARENT_PROCESS);
}
}
}

// Now that the windows fix is successfully setup, we can safely exit on the error
// and it will display properly to the user, or carry forward with the program
// and properly display our logging to the user. Since `e.exit()` returns a `!`,
// we can return the Ok(Opts) and carry forward with our program.
match opts_result {
Ok(opts) => opts,
Err(e) => {
// Apparently on `--version`, there is no "error message" that gets displayed
// like with `--help` and actual clap errors. It gets printed before we
// ever hit our console fix for windows, so let's manually print it
// before exiting
#[cfg(target_os = "windows")]
{
if !is_debug && e.kind == clap::ErrorKind::VersionDisplayed {
print!("Grin GUI {}", VERSION);
}
}
// Now that the windows fix is successfully setup, we can safely exit on the error
// and it will display properly to the user, or carry forward with the program
// and properly display our logging to the user. Since `e.exit()` returns a `!`,
// we can return the Ok(Opts) and carry forward with our program.
match opts_result {
Ok(opts) => opts,
Err(e) => {
// Apparently on `--version`, there is no "error message" that gets displayed
// like with `--help` and actual clap errors. It gets printed before we
// ever hit our console fix for windows, so let's manually print it
// before exiting
#[cfg(target_os = "windows")]
{
if !is_debug && e.kind == clap::ErrorKind::VersionDisplayed {
print!("Grin GUI {}", VERSION);
}
}

e.exit();
}
}
e.exit();
}
}
}

#[derive(Debug, StructOpt)]
Expand All @@ -68,64 +68,15 @@ pub fn validate_opts_or_exit(
author = env!("CARGO_PKG_AUTHORS"),
setting = AppSettings::DisableHelpSubcommand)]
pub struct Opts {
#[structopt(long = "data", help = "Path to a custom data directory for the app")]
pub data_directory: Option<PathBuf>,
#[structopt(long = "aa", help = "Enable / Disable Anti-aliasing (true / false)")]
pub antialiasing: Option<bool>,
#[structopt(subcommand)]
pub command: Option<Command>,
#[structopt(long, hidden = true)]
pub self_update_temp: Option<PathBuf>,
#[structopt(long = "data", help = "Path to a custom data directory for the app")]
pub data_directory: Option<PathBuf>,
#[structopt(long = "aa", help = "Enable / Disable Anti-aliasing (true / false)")]
pub antialiasing: Option<bool>,
#[structopt(subcommand)]
pub command: Option<Command>,
#[structopt(long, hidden = true)]
pub self_update_temp: Option<PathBuf>,
}

#[derive(Debug, StructOpt)]
pub enum Command {
/// Update all addons, WeakAura and Plater auras
Update,
/// Update all addons
UpdateAddons,
/// Update all WeakAura and Plater auras
UpdateAuras,
/// Install an addon
Install {
#[structopt()]
/// source url [Github & Gitlab currently supported]
url: Uri,
},
/// Backup your WTF and/or AddOns folders
Backup {
#[structopt(short, long, default_value = "all", parse(try_from_str = str_to_backup_folder), possible_values = &["all","wtf","addons","config", "screenshots", "fonts"])]
/// folder to backup
backup_folder: BackupFolder,
#[structopt()]
/// folder to save backups to
destination: PathBuf,
},
/// Add a World of Warcraft path
PathAdd {
/// path to the World of Warcraft directory
path: PathBuf,
},
}

#[derive(Debug, Clone, Copy)]
pub enum BackupFolder {
All,
AddOns,
Wtf,
Config,
Screenshots,
Fonts,
}

fn str_to_backup_folder(s: &str) -> Result<BackupFolder, &'static str> {
match s {
"all" => Ok(BackupFolder::All),
"wtf" => Ok(BackupFolder::Wtf),
"addons" => Ok(BackupFolder::AddOns),
"config" => Ok(BackupFolder::Config),
"screenshots" => Ok(BackupFolder::Screenshots),
"fonts" => Ok(BackupFolder::Fonts),
_ => Err("valid values are ['all','wtf','addons','config','screenshots','fonts']"),
}
}
pub enum Command {}
Loading