1#![cfg_attr(target_os = "windows", allow(unused, dead_code))]
2
3use clap::Parser;
4use remote_server::Commands;
5use std::path::PathBuf;
6
7#[derive(Parser)]
8#[command(disable_version_flag = true)]
9struct Cli {
10 #[command(subcommand)]
11 command: Option<Commands>,
12 /// Used for SSH/Git password authentication, to remove the need for netcat as a dependency,
13 /// by having Zed act like netcat communicating over a Unix socket.
14 #[arg(long, hide = true)]
15 askpass: Option<String>,
16 /// Used for recording minidumps on crashes by having the server run a separate
17 /// process communicating over a socket.
18 #[arg(long, hide = true)]
19 crash_handler: Option<PathBuf>,
20 /// Used for loading the environment from the project.
21 #[arg(long, hide = true)]
22 printenv: bool,
23}
24
25#[cfg(windows)]
26fn main() {
27 unimplemented!()
28}
29
30#[cfg(not(windows))]
31fn main() -> anyhow::Result<()> {
32 let cli = Cli::parse();
33
34 if let Some(socket_path) = &cli.askpass {
35 askpass::main(socket_path);
36 return Ok(());
37 }
38
39 if let Some(socket) = &cli.crash_handler {
40 crashes::crash_server(socket.as_path());
41 return Ok(());
42 }
43
44 if cli.printenv {
45 util::shell_env::print_env();
46 return Ok(());
47 }
48
49 if let Some(command) = cli.command {
50 remote_server::run(command)
51 } else {
52 eprintln!("usage: remote <run|proxy|version>");
53 std::process::exit(1);
54 }
55}