From 613ca00b1ccfbc2ff52863fc507f747f8d1cf772 Mon Sep 17 00:00:00 2001 From: Reactor Scram Date: Thu, 18 Jan 2024 22:02:38 -0600 Subject: [PATCH] refactor(windows): move CLI things inside client.rs (#3305) Both modules were small, and it's inconvenient to open two files to add a new subcommand, so I want to combine them. --- rust/windows-client/src-tauri/src/client.rs | 36 ++++++++++++++++--- .../src-tauri/src/client/cli.rs | 31 ---------------- .../src-tauri/src/client/debug_commands.rs | 2 +- 3 files changed, 33 insertions(+), 36 deletions(-) delete mode 100644 rust/windows-client/src-tauri/src/client/cli.rs diff --git a/rust/windows-client/src-tauri/src/client.rs b/rust/windows-client/src-tauri/src/client.rs index 66fb58ff9..9f71919ce 100644 --- a/rust/windows-client/src-tauri/src/client.rs +++ b/rust/windows-client/src-tauri/src/client.rs @@ -1,10 +1,8 @@ use anyhow::Result; -use clap::Parser; -use cli::CliCommands as Cmd; +use clap::{Args, Parser}; use std::{os::windows::process::CommandExt, process::Command}; mod auth; -mod cli; mod crash_handling; mod debug_commands; mod deep_link; @@ -69,7 +67,7 @@ const CREATE_NO_WINDOW: u32 = 0x08000000; /// In steady state, the only processes running will be the GUI and the crash handler. pub(crate) fn run() -> Result<()> { std::panic::set_hook(Box::new(tracing_panic::panic_hook)); - let cli = cli::Cli::parse(); + let cli = Cli::parse(); match cli.command { None => { @@ -121,6 +119,36 @@ pub(crate) fn run() -> Result<()> { } } +#[derive(Parser)] +#[command(author, version, about, long_about = None)] +pub struct Cli { + #[command(subcommand)] + pub command: Option, + #[arg(long, hide = true)] + pub crash_on_purpose: bool, + #[arg(long, hide = true)] + pub inject_faults: bool, +} + +#[derive(clap::Subcommand)] +pub enum Cmd { + CrashHandlerServer, + Debug, + DebugCrash, + DebugHostname, + DebugNetworkChanges, + DebugPipeServer, + DebugWintun, + Elevated, + OpenDeepLink(DeepLink), + RegisterDeepLink, +} + +#[derive(Args)] +pub struct DeepLink { + pub url: url::Url, +} + #[cfg(test)] mod tests { use anyhow::Result; diff --git a/rust/windows-client/src-tauri/src/client/cli.rs b/rust/windows-client/src-tauri/src/client/cli.rs deleted file mode 100644 index 24fd6a6c9..000000000 --- a/rust/windows-client/src-tauri/src/client/cli.rs +++ /dev/null @@ -1,31 +0,0 @@ -use clap::{Args, Parser}; - -#[derive(Parser)] -#[command(author, version, about, long_about = None)] -pub struct Cli { - #[command(subcommand)] - pub command: Option, - #[arg(long, hide = true)] - pub crash_on_purpose: bool, - #[arg(long, hide = true)] - pub inject_faults: bool, -} - -#[derive(clap::Subcommand)] -pub enum CliCommands { - CrashHandlerServer, - Debug, - DebugCrash, - DebugHostname, - DebugNetworkChanges, - DebugPipeServer, - DebugWintun, - Elevated, - OpenDeepLink(DeepLink), - RegisterDeepLink, -} - -#[derive(Args)] -pub struct DeepLink { - pub url: url::Url, -} diff --git a/rust/windows-client/src-tauri/src/client/debug_commands.rs b/rust/windows-client/src-tauri/src/client/debug_commands.rs index 4a0fc5158..7275a08e1 100644 --- a/rust/windows-client/src-tauri/src/client/debug_commands.rs +++ b/rust/windows-client/src-tauri/src/client/debug_commands.rs @@ -1,7 +1,7 @@ //! CLI subcommands used to test features / dependencies before integrating //! them with the GUI, or to exercise features programmatically. -use crate::client::cli::Cli; +use crate::client::Cli; use anyhow::Result; use tokio::runtime::Runtime; use windows::Win32::System::Com::{CoInitializeEx, CoUninitialize, COINIT_MULTITHREADED};