diff --git a/crates/molotov-cli/src/commands.rs b/crates/molotov-cli/src/commands.rs new file mode 100644 index 0000000..2624341 --- /dev/null +++ b/crates/molotov-cli/src/commands.rs @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +use clap::{Parser, Subcommand}; + +#[derive(Parser, Debug)] +#[command(name = "molotov", author, version, about = "Native Roblox Runtime for Linux", long_about = None)] +pub struct Cli { + #[command(subcommand)] + pub command: Option, +} + +#[derive(Subcommand, Debug)] +pub enum Commands { + /// Launch Roblox with the active profile + Launch { + #[arg(short, long)] + place_id: Option, + #[arg(long)] + safe_mode: bool, + }, + /// Check for and download the latest Roblox version + Update, + /// Apply or inspect FastFlag settings + Fflags { + #[arg(short, long)] + profile: Option, + #[arg(short, long)] + list: bool, + }, + /// Clean old versions and cached files + Clean, + /// Show system diagnostics and status + Diagnostics, +} diff --git a/crates/molotov-cli/src/lib.rs b/crates/molotov-cli/src/lib.rs index 4feb80a..8d91df2 100644 --- a/crates/molotov-cli/src/lib.rs +++ b/crates/molotov-cli/src/lib.rs @@ -1,4 +1,38 @@ // SPDX-License-Identifier: GPL-3.0-or-later -pub fn run(_args: &[String]) { - println!("Molotov CLI placeholder"); +pub mod commands; +use clap::Parser; +use commands::{Cli, Commands}; + +pub fn run(args: &[String]) { + let mut full_args = vec!["molotov".to_string()]; + full_args.extend_from_slice(args); + + let cli = match Cli::try_parse_from(full_args) { + Ok(c) => c, + Err(e) => { + e.print().ok(); + return; + } + }; + + match cli.command { + Some(Commands::Launch { place_id, safe_mode }) => { + println!("๐Ÿš€ Launching Molotov (Place: {:?}, Safe Mode: {})", place_id, safe_mode); + } + Some(Commands::Update) => { + println!("๐Ÿ”„ Checking for Roblox updates..."); + } + Some(Commands::Fflags { profile, list }) => { + println!("โš™๏ธ FastFlag manager (Profile: {:?}, List: {})", profile, list); + } + Some(Commands::Clean) => { + println!("๐Ÿงน Cleaning old versions and temporary cache..."); + } + Some(Commands::Diagnostics) => { + println!("๐Ÿฉบ Running Molotov system diagnostics..."); + } + None => { + println!("No subcommand specified. Running in GUI mode."); + } + } } diff --git a/crates/molotov-cli/tests/cli_test.rs b/crates/molotov-cli/tests/cli_test.rs new file mode 100644 index 0000000..6ae7db4 --- /dev/null +++ b/crates/molotov-cli/tests/cli_test.rs @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +use clap::Parser; +use molotov_cli::commands::Cli; + +#[test] +fn test_cli_parse_launch_place() { + let parsed = Cli::try_parse_from(["molotov", "launch", "--place-id", "1818"]); + assert!(parsed.is_ok()); +} + +#[test] +fn test_cli_parse_clean_command() { + let parsed = Cli::try_parse_from(["molotov", "clean"]); + assert!(parsed.is_ok()); +}