From fd6af70eeafee6bb80c6121b52e64b7fc618ee81 Mon Sep 17 00:00:00 2001 From: WaviestBalloon <31796727+WaviestBalloon@users.noreply.github.com> Date: Fri, 25 Aug 2023 01:02:54 +0100 Subject: [PATCH] Fix: Install missing args warning, change strs to json! and more --- src/args/initialise.rs | 4 ++++ src/args/install.rs | 13 ++++++++----- src/main.rs | 6 +++++- src/utils/argparse.rs | 2 +- src/utils/installation.rs | 2 +- src/utils/setup.rs | 6 +++++- 6 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/args/initialise.rs b/src/args/initialise.rs index c18d643..78fea61 100644 --- a/src/args/initialise.rs +++ b/src/args/initialise.rs @@ -1,4 +1,6 @@ use std::fs; +use serde_json::json; + use crate::utils::setup; use crate::utils::terminal::*; use crate::utils::proton; @@ -71,6 +73,8 @@ pub fn main() { success("config.json updated with Proton paths"); } + configuration::update_config(json!({ "global": {} }), "global"); + println!(); // "Print a newline (for aesthetics" -GitHub copilot, providing dumb crap since 2022 success("Applejuice has been initialised!\nTo get started, run 'applejuicecli --help'\nOr to dive right in, run 'applejuicecli --install client'"); } diff --git a/src/args/install.rs b/src/args/install.rs index 47de2e7..6dc3a09 100644 --- a/src/args/install.rs +++ b/src/args/install.rs @@ -1,4 +1,6 @@ use std::{fs, env::var}; +use serde_json::json; + use crate::utils::{terminal::*, installation, setup, configuration, argparse}; const HELP_TEXT: &str = "\nUsage: --install [type] [?removeolder] [?migratefflags] \nInstalls Roblox Client or Roblox Studio\n\nOptions:\n\tclient\tInstalls the Roblox Client\n\tstudio\tInstalls Roblox Studio\n\nExample: --install client zcanary --removeolder --migratefflags"; @@ -34,6 +36,10 @@ fn download_and_install(version_hash: &str, channel: &str, raw_args: Vec, version_hash_arg: Option, raw_args: Vec>) { let version_hash: String; let mut channel: String = "LIVE".to_string(); - let mut _protocol: bool = false; - let mut _uncap_fps_fflag: bool = false; if !channel_arg.is_some() { status("Defaulting to LIVE channel..."); @@ -110,7 +113,7 @@ fn install_studio(channel_arg: Option, version_hash_arg: Option, pub fn main(args: Vec>) { let binding = argparse::get_param_value(args.clone(), "install"); let parsed_args = binding.split(" ").collect::>(); - if parsed_args.len() == 0 { + if parsed_args.len() == 0 || parsed_args[0] == "blank" { error(format!("No command line arguments provided for install!{}", HELP_TEXT)); } let install_type: &str = &parsed_args[0]; diff --git a/src/main.rs b/src/main.rs index 5b51fb5..cab580f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,13 @@ -use std::env; +use std::{env, process}; mod utils; // Import utilities that are not necessarily commands mod args; // Import modules which act as a handler for certain command parameters use crate::utils::{terminal::*, *}; fn main() { + if env::consts::OS != "linux" { + error(format!("Applejuice is a Linux-only application and is not designed to be ran on any operating system other than a Linux-based system.\nYour OS identifies itself as {}!\n{}", env::consts::OS, if env::consts::OS == "windows" { "Since you are using Windows, consider using Bloxstrap: https://github.com/pizzaboxer/bloxstrap/\n" } else { "" })); + process::exit(1); + } let args: Vec = env::args().collect(); if !setup::confirm_applejuice_data_folder_existence() { // Initialisation warning warning("Applejuice has not been initialised yet! Attempting to initialise..."); diff --git a/src/utils/argparse.rs b/src/utils/argparse.rs index 2120b64..4f0c1dd 100644 --- a/src/utils/argparse.rs +++ b/src/utils/argparse.rs @@ -2,7 +2,7 @@ pub fn get_param_value(command_vector: Vec>, value_to_find for command in command_vector.iter() { if command[0].0 == value_to_find.to_string() { if command[0].1.is_empty() { - return "true".to_string(); + return "blank".to_string(); } else { return command[0].1.to_string(); } diff --git a/src/utils/installation.rs b/src/utils/installation.rs index ee60868..13d022d 100644 --- a/src/utils/installation.rs +++ b/src/utils/installation.rs @@ -103,7 +103,7 @@ pub fn get_binary_type(package_manifest: Vec<&str>) -> &str { break; } } - if binary == "" { + if binary.is_empty() { error("Could not determine binary type for provided package menifest!"); } diff --git a/src/utils/setup.rs b/src/utils/setup.rs index 4ceb2db..f7d0567 100644 --- a/src/utils/setup.rs +++ b/src/utils/setup.rs @@ -1,4 +1,6 @@ use std::{fs, env::var}; +use serde_json::json; + use crate::utils::terminal::*; pub fn confirm_applejuice_data_folder_existence() -> bool { // Check whether the .applejuice data folder exists under $HOME/.applejuice @@ -29,8 +31,10 @@ pub fn construct_applejuice_data_folder() { // Construct the .applejuice data fo } } + status("Creating README.txt..."); fs::write(format!("{}/{}", path, "README.txt"), "Hey! Welcome to the cool zone...\n\n\tIf you want a fresh start, delete this folder and Applejuice will forget everything!").expect("Failed to create the README file!"); - fs::write(format!("{}/{}", path, "config.json"), "{}").expect("Failed to create the config file!"); + status("Creating config.json..."); + fs::write(format!("{}/{}", path, "config.json"), json!({}).to_string()).expect("Failed to create the config file!"); } pub fn confirm_existence(providedpath: &str) -> bool { // Check whether a item exists in the .applejuice data folder or a ancestor to it