discord-proxy 0.1.0

Windows-first Discord process-local proxy launcher
Documentation
use clap::{Args, Parser, Subcommand};
use std::path::PathBuf;

#[derive(Debug, Parser)]
#[command(name = "discord-proxy")]
#[command(about = "Start Discord with a process-local proxy")]
pub struct Cli {
    #[arg(short, long, global = true, value_name = "FILE")]
    pub config: Option<PathBuf>,

    #[command(subcommand)]
    pub command: Commands,
}

#[derive(Debug, Subcommand)]
pub enum Commands {
    /// Start Discord with proxy settings.
    Launch(LaunchArgs),
    /// Print the detected Discord installation without launching it.
    Doctor(DoctorArgs),
    /// Run only the local HTTP CONNECT proxy bridge.
    Bridge(BridgeArgs),
}

#[derive(Debug, Args)]
pub struct LaunchArgs {
    /// Upstream proxy URL, for example http://127.0.0.1:1080 or socks5://user:pass@127.0.0.1:1080.
    #[arg(short, long)]
    pub proxy: Option<String>,

    /// Discord channel: stable, canary, ptb, or development.
    #[arg(long)]
    pub channel: Option<String>,

    /// Discord root directory that contains Update.exe and app-* folders.
    #[arg(long, value_name = "DIR")]
    pub discord_dir: Option<PathBuf>,

    /// Local bridge listen port. Defaults to a random available loopback port.
    #[arg(long)]
    pub listen_port: Option<u16>,

    /// Do not start the local bridge even when SOCKS or authentication would normally require it.
    #[arg(long)]
    pub no_bridge: bool,

    /// Print the launch plan without starting Discord.
    #[arg(long)]
    pub dry_run: bool,
}

#[derive(Debug, Args)]
pub struct DoctorArgs {
    /// Discord channel: stable, canary, ptb, or development.
    #[arg(long)]
    pub channel: Option<String>,

    /// Discord root directory that contains Update.exe and app-* folders.
    #[arg(long, value_name = "DIR")]
    pub discord_dir: Option<PathBuf>,
}

#[derive(Debug, Args)]
pub struct BridgeArgs {
    /// Upstream proxy URL.
    #[arg(short, long)]
    pub proxy: String,

    /// Local bridge listen port. Defaults to a random available loopback port.
    #[arg(long)]
    pub listen_port: Option<u16>,
}