Skip to main content

discord_proxy/
cli.rs

1use clap::{Args, Parser, Subcommand};
2use std::path::PathBuf;
3
4#[derive(Debug, Parser)]
5#[command(name = "discord-proxy")]
6#[command(about = "Start Discord with a process-local proxy")]
7pub struct Cli {
8    #[arg(short, long, global = true, value_name = "FILE")]
9    pub config: Option<PathBuf>,
10
11    #[command(subcommand)]
12    pub command: Commands,
13}
14
15#[derive(Debug, Subcommand)]
16pub enum Commands {
17    /// Start Discord with proxy settings.
18    Launch(LaunchArgs),
19    /// Print the detected Discord installation without launching it.
20    Doctor(DoctorArgs),
21    /// Run only the local HTTP CONNECT proxy bridge.
22    Bridge(BridgeArgs),
23}
24
25#[derive(Debug, Args)]
26pub struct LaunchArgs {
27    /// Upstream proxy URL, for example http://127.0.0.1:1080 or socks5://user:pass@127.0.0.1:1080.
28    #[arg(short, long)]
29    pub proxy: Option<String>,
30
31    /// Discord channel: stable, canary, ptb, or development.
32    #[arg(long)]
33    pub channel: Option<String>,
34
35    /// Discord root directory that contains Update.exe and app-* folders.
36    #[arg(long, value_name = "DIR")]
37    pub discord_dir: Option<PathBuf>,
38
39    /// Local bridge listen port. Defaults to a random available loopback port.
40    #[arg(long)]
41    pub listen_port: Option<u16>,
42
43    /// Do not start the local bridge even when SOCKS or authentication would normally require it.
44    #[arg(long)]
45    pub no_bridge: bool,
46
47    /// Print the launch plan without starting Discord.
48    #[arg(long)]
49    pub dry_run: bool,
50}
51
52#[derive(Debug, Args)]
53pub struct DoctorArgs {
54    /// Discord channel: stable, canary, ptb, or development.
55    #[arg(long)]
56    pub channel: Option<String>,
57
58    /// Discord root directory that contains Update.exe and app-* folders.
59    #[arg(long, value_name = "DIR")]
60    pub discord_dir: Option<PathBuf>,
61}
62
63#[derive(Debug, Args)]
64pub struct BridgeArgs {
65    /// Upstream proxy URL.
66    #[arg(short, long)]
67    pub proxy: String,
68
69    /// Local bridge listen port. Defaults to a random available loopback port.
70    #[arg(long)]
71    pub listen_port: Option<u16>,
72}