Merge #954: [GUI] Add version args

601bd08c0c1b5b86f4a016fa8d4acb080416cd83 add -v / --version args (pythcoiner)

Pull request description:

  fixes #896

  ![image](https://github.com/wizardsardine/liana/assets/124568858/c90ff9ff-41b9-41f3-8938-387c0eb81f38)

ACKs for top commit:
  edouardparis:
    ACK 601bd08c0c1b5b86f4a016fa8d4acb080416cd83

Tree-SHA512: ca54927141bc1115fae04480dbe1867cafd30955278e1845d4170079d4ce13300e722b11bbe73f85e1e8862f0b5576a14a1b5bb5997bf23e33dc8af6320cbc36
This commit is contained in:
edouardparis 2024-02-02 15:49:45 +01:00
commit 3fcbb0b67d
No known key found for this signature in database
GPG Key ID: E65F7A089C20DC8F

View File

@ -1,6 +1,6 @@
#![windows_subsystem = "windows"] #![windows_subsystem = "windows"]
use std::{error::Error, io::Write, path::PathBuf, str::FromStr}; use std::{error::Error, io::Write, path::PathBuf, process, str::FromStr};
use iced::{executor, Application, Command, Settings, Subscription}; use iced::{executor, Application, Command, Settings, Subscription};
use tracing::{error, info}; use tracing::{error, info};
@ -21,6 +21,7 @@ use liana_gui::{
launcher::{self, Launcher}, launcher::{self, Launcher},
loader::{self, Loader}, loader::{self, Loader},
logger::Logger, logger::Logger,
VERSION,
}; };
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
@ -32,6 +33,12 @@ enum Arg {
fn parse_args(args: Vec<String>) -> Result<Vec<Arg>, Box<dyn Error>> { fn parse_args(args: Vec<String>) -> Result<Vec<Arg>, Box<dyn Error>> {
let mut res = Vec::new(); let mut res = Vec::new();
if args.len() > 1 && (args[1] == "--version" || args[1] == "-v") {
eprintln!("{}", VERSION);
process::exit(1);
}
for (i, arg) in args.iter().enumerate() { for (i, arg) in args.iter().enumerate() {
if arg == "--conf" { if arg == "--conf" {
if let Some(a) = args.get(i + 1) { if let Some(a) = args.get(i + 1) {