OneLauncher-Cracked/packages/oneclient_app/src/cli.rs
oiupoyt 163eb0ac0c
Some checks are pending
Release Multiplatform Binaries / build (deb,appimage, linux-x86_64, ubuntu-22.04, x86_64-unknown-linux-gnu) (push) Waiting to run
Release Multiplatform Binaries / build (dmg,app, macos-arm64, macos-14, aarch64-apple-darwin) (push) Waiting to run
Release Multiplatform Binaries / build (dmg,app, macos-x86_64, macos-14, x86_64-apple-darwin) (push) Waiting to run
Release Multiplatform Binaries / build (nsis, windows-x86_64, windows-latest, x86_64-pc-windows-msvc) (push) Waiting to run
Release Multiplatform Binaries / create-release (push) Blocked by required conditions
feat: update base to official upstream 2.3.1 with all cracked features intact (2.3.1-c1)
- Rebased onto official Polyfrost OneLauncher v2.3.1 (commit 0e49c691)
- Preserved 100% offline authentication without requiring Microsoft accounts
- Integrated custom 3D offline skin changer with UUID character slot targeting
- Maintained CustomSkinLoader auto-configuration for Ely.by and SkinRestorer
- Maintained direct GitHub Releases auto-updater pointing to oiupoyt/OneLauncher-Cracked
- Maintained mods filter popover fix eliminating text ghosting/duplication
- Configured dev profile to prevent debug symbol bloat
2026-09-07 17:38:22 +05:30

84 lines
2.3 KiB
Rust

#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct Cli {
pub launch: Option<String>,
}
impl Cli {
fn from_args(args: impl IntoIterator<Item = String>) -> Self {
let mut cli = Self::default();
let mut args = args.into_iter();
while let Some(arg) = args.next() {
if let Some(value) = arg.strip_prefix("--launch=") {
cli.launch = non_empty(value.to_string());
} else if arg == "--launch" {
cli.launch = args.next().and_then(non_empty);
} else if let Some(folder) = crate::protocol::parse_launch_url(&arg) {
cli.launch = Some(folder);
}
}
cli
}
}
fn non_empty(value: String) -> Option<String> {
let trimmed = value.trim();
(!trimmed.is_empty()).then(|| trimmed.to_string())
}
#[must_use]
pub fn parse() -> Cli {
Cli::from_args(std::env::args().skip(1))
}
#[cfg(test)]
mod tests {
use super::*;
fn parse(args: &[&str]) -> Cli {
Cli::from_args(args.iter().map(|s| (*s).to_string()))
}
#[test]
fn no_arguments_is_an_ordinary_start() {
assert_eq!(parse(&[]).launch, None);
}
#[test]
fn both_spellings_carry_the_folder() {
assert_eq!(parse(&["--launch", "fabric-1-20"]).launch.as_deref(), Some("fabric-1-20"));
assert_eq!(parse(&["--launch=fabric-1-20"]).launch.as_deref(), Some("fabric-1-20"));
}
#[test]
fn a_blank_folder_is_no_request_at_all() {
assert_eq!(parse(&["--launch", " "]).launch, None);
assert_eq!(parse(&["--launch="]).launch, None);
assert_eq!(parse(&["--launch"]).launch, None);
}
#[test]
fn spaces_survive_the_round_trip() {
assert_eq!(
parse(&["--launch", "My Pack (1.8.9)"]).launch.as_deref(),
Some("My Pack (1.8.9)"),
);
}
#[test]
fn unknown_flags_are_ignored_not_fatal() {
assert_eq!(parse(&["--verbose", "--launch", "x", "leftover"]).launch.as_deref(), Some("x"));
}
#[test]
fn a_launch_url_is_accepted_as_a_bare_argument() {
let url = crate::protocol::launch_url("26.1.2 Fabric");
assert_eq!(parse(&[&url]).launch.as_deref(), Some("26.1.2 Fabric"));
}
#[test]
fn a_url_that_is_not_ours_is_not_a_launch() {
assert_eq!(parse(&["https://polyfrost.org"]).launch, None);
}
}