1#![cfg_attr(target_os = "windows", allow(unused, dead_code))]
2
3use anyhow::Result;
4use clap::{Parser, Subcommand};
5use std::path::PathBuf;
6
7#[derive(Parser)]
8#[command(disable_version_flag = true)]
9struct Cli {
10 #[command(subcommand)]
11 command: Option<Commands>,
12}
13
14#[derive(Subcommand)]
15enum Commands {
16 Run {
17 #[arg(long)]
18 log_file: PathBuf,
19 #[arg(long)]
20 pid_file: PathBuf,
21 #[arg(long)]
22 stdin_socket: PathBuf,
23 #[arg(long)]
24 stdout_socket: PathBuf,
25 },
26 Proxy {
27 #[arg(long)]
28 identifier: String,
29 },
30 Version,
31}
32
33#[cfg(windows)]
34fn main() {
35 unimplemented!()
36}
37
38#[cfg(not(windows))]
39fn main() -> Result<()> {
40 use remote_server::unix::{execute_proxy, execute_run, init};
41
42 let cli = Cli::parse();
43
44 match cli.command {
45 Some(Commands::Run {
46 log_file,
47 pid_file,
48 stdin_socket,
49 stdout_socket,
50 }) => {
51 init(Some(log_file))?;
52 execute_run(pid_file, stdin_socket, stdout_socket)
53 }
54 Some(Commands::Proxy { identifier }) => {
55 init(None)?;
56 execute_proxy(identifier)
57 }
58 Some(Commands::Version) => {
59 eprintln!("{}", env!("ZED_PKG_VERSION"));
60 Ok(())
61 }
62 None => {
63 eprintln!("usage: remote <run|proxy|version>");
64 std::process::exit(1);
65 }
66 }
67}