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.
This commit is contained in:
Reactor Scram
2024-01-18 22:02:38 -06:00
committed by GitHub
parent 2a62e3961e
commit 613ca00b1c
3 changed files with 33 additions and 36 deletions

View File

@@ -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<Cmd>,
#[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;

View File

@@ -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<CliCommands>,
#[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,
}

View File

@@ -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};