cli.rs

 1pub use ipc_channel::ipc;
 2use serde::{Deserialize, Serialize};
 3
 4#[derive(Serialize, Deserialize)]
 5pub struct IpcHandshake {
 6    pub requests: ipc::IpcSender<CliRequest>,
 7    pub responses: ipc::IpcReceiver<CliResponse>,
 8}
 9
10#[derive(Debug, Serialize, Deserialize)]
11pub enum CliRequest {
12    // The filed is named `path` for compatibility, but now CLI can request
13    // opening a path at a certain row and/or column: `some/path:123` and `some/path:123:456`.
14    //
15    // Since Zed CLI has to be installed separately, there can be situations when old CLI is
16    // querying new Zed editors, support both formats by using `String` here and parsing it on Zed side later.
17    Open { paths: Vec<String>, wait: bool },
18}
19
20#[derive(Debug, Serialize, Deserialize)]
21pub enum CliResponse {
22    Ping,
23    Stdout { message: String },
24    Stderr { message: String },
25    Exit { status: i32 },
26}
27
28/// When Zed started not as an *.app but as a binary (e.g. local development),
29/// there's a possibility to tell it to behave "regularly".
30pub const FORCE_CLI_MODE_ENV_VAR_NAME: &str = "ZED_FORCE_CLI_MODE";