Extract cli's communication with Zed to a separate crate
This commit is contained in:
parent
990dac51aa
commit
f34014b279
8 changed files with 68 additions and 31 deletions
69
Cargo.lock
generated
69
Cargo.lock
generated
|
@ -1230,6 +1230,7 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap 3.2.25",
|
"clap 3.2.25",
|
||||||
|
"cli_rpc",
|
||||||
"core-foundation",
|
"core-foundation",
|
||||||
"core-services",
|
"core-services",
|
||||||
"dirs 3.0.2",
|
"dirs 3.0.2",
|
||||||
|
@ -1240,6 +1241,15 @@ dependencies = [
|
||||||
"util",
|
"util",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cli_rpc"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"ipc-channel",
|
||||||
|
"serde",
|
||||||
|
"serde_derive",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "client"
|
name = "client"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -1855,7 +1865,6 @@ checksum = "14d05c10f541ae6f3bc5b3d923c20001f47db7d5f0b2bc6ad16490133842db79"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"libc",
|
"libc",
|
||||||
"libnghttp2-sys",
|
|
||||||
"libz-sys",
|
"libz-sys",
|
||||||
"openssl-sys",
|
"openssl-sys",
|
||||||
"pkg-config",
|
"pkg-config",
|
||||||
|
@ -2885,20 +2894,12 @@ dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-task",
|
"async-task",
|
||||||
"backtrace",
|
"backtrace",
|
||||||
"bindgen",
|
|
||||||
"block",
|
|
||||||
"cc",
|
|
||||||
"cocoa",
|
|
||||||
"collections",
|
"collections",
|
||||||
"core-foundation",
|
|
||||||
"core-graphics",
|
|
||||||
"core-text",
|
|
||||||
"ctor",
|
"ctor",
|
||||||
"dhat",
|
"dhat",
|
||||||
"env_logger 0.9.3",
|
"env_logger 0.9.3",
|
||||||
"etagere",
|
"etagere",
|
||||||
"font-kit",
|
"font-kit",
|
||||||
"foreign-types",
|
|
||||||
"futures 0.3.28",
|
"futures 0.3.28",
|
||||||
"gpui_macros",
|
"gpui_macros",
|
||||||
"image",
|
"image",
|
||||||
|
@ -2906,9 +2907,7 @@ dependencies = [
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"log",
|
"log",
|
||||||
"media",
|
"media",
|
||||||
"metal",
|
|
||||||
"num_cpus",
|
"num_cpus",
|
||||||
"objc",
|
|
||||||
"ordered-float",
|
"ordered-float",
|
||||||
"parking",
|
"parking",
|
||||||
"parking_lot 0.11.2",
|
"parking_lot 0.11.2",
|
||||||
|
@ -2936,6 +2935,41 @@ dependencies = [
|
||||||
"waker-fn",
|
"waker-fn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "gpui_mac"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"async-task",
|
||||||
|
"bindgen",
|
||||||
|
"block",
|
||||||
|
"cc",
|
||||||
|
"cocoa",
|
||||||
|
"collections",
|
||||||
|
"core-foundation",
|
||||||
|
"core-graphics",
|
||||||
|
"core-text",
|
||||||
|
"ctor",
|
||||||
|
"etagere",
|
||||||
|
"font-kit",
|
||||||
|
"foreign-types",
|
||||||
|
"gpui",
|
||||||
|
"log",
|
||||||
|
"media",
|
||||||
|
"metal",
|
||||||
|
"objc",
|
||||||
|
"ordered-float",
|
||||||
|
"parking_lot 0.11.2",
|
||||||
|
"pathfinder_geometry",
|
||||||
|
"postage",
|
||||||
|
"resvg",
|
||||||
|
"smol",
|
||||||
|
"time 0.3.21",
|
||||||
|
"tiny-skia",
|
||||||
|
"usvg",
|
||||||
|
"uuid 1.3.2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpui_macros"
|
name = "gpui_macros"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -3691,16 +3725,6 @@ version = "0.2.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "348108ab3fba42ec82ff6e9564fc4ca0247bdccdc68dd8af9764bbc79c3c8ffb"
|
checksum = "348108ab3fba42ec82ff6e9564fc4ca0247bdccdc68dd8af9764bbc79c3c8ffb"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "libnghttp2-sys"
|
|
||||||
version = "0.1.7+1.45.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "57ed28aba195b38d5ff02b9170cbff627e336a20925e43b4945390401c5dc93f"
|
|
||||||
dependencies = [
|
|
||||||
"cc",
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libsqlite3-sys"
|
name = "libsqlite3-sys"
|
||||||
version = "0.24.2"
|
version = "0.24.2"
|
||||||
|
@ -8919,7 +8943,7 @@ dependencies = [
|
||||||
"breadcrumbs",
|
"breadcrumbs",
|
||||||
"call",
|
"call",
|
||||||
"chrono",
|
"chrono",
|
||||||
"cli",
|
"cli_rpc",
|
||||||
"client",
|
"client",
|
||||||
"clock",
|
"clock",
|
||||||
"collab_ui",
|
"collab_ui",
|
||||||
|
@ -8941,6 +8965,7 @@ dependencies = [
|
||||||
"fuzzy",
|
"fuzzy",
|
||||||
"go_to_line",
|
"go_to_line",
|
||||||
"gpui",
|
"gpui",
|
||||||
|
"gpui_mac",
|
||||||
"ignore",
|
"ignore",
|
||||||
"image",
|
"image",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
|
|
|
@ -6,6 +6,7 @@ members = [
|
||||||
"crates/breadcrumbs",
|
"crates/breadcrumbs",
|
||||||
"crates/call",
|
"crates/call",
|
||||||
"crates/cli",
|
"crates/cli",
|
||||||
|
"crates/cli_rpc",
|
||||||
"crates/client",
|
"crates/client",
|
||||||
"crates/clock",
|
"crates/clock",
|
||||||
"crates/collab",
|
"crates/collab",
|
||||||
|
@ -27,6 +28,7 @@ members = [
|
||||||
"crates/git",
|
"crates/git",
|
||||||
"crates/go_to_line",
|
"crates/go_to_line",
|
||||||
"crates/gpui",
|
"crates/gpui",
|
||||||
|
"crates/gpui_mac",
|
||||||
"crates/gpui_macros",
|
"crates/gpui_macros",
|
||||||
"crates/install_cli",
|
"crates/install_cli",
|
||||||
"crates/journal",
|
"crates/journal",
|
||||||
|
@ -79,7 +81,7 @@ env_logger = { version = "0.9" }
|
||||||
futures = { version = "0.3" }
|
futures = { version = "0.3" }
|
||||||
globset = { version = "0.4" }
|
globset = { version = "0.4" }
|
||||||
indoc = "1"
|
indoc = "1"
|
||||||
isahc = "1.7.2"
|
isahc = {version = "1.7.2", default-features = false, features = ["text-decoding"]}
|
||||||
lazy_static = { version = "1.4.0" }
|
lazy_static = { version = "1.4.0" }
|
||||||
log = { version = "0.4.16", features = ["kv_unstable_serde"] }
|
log = { version = "0.4.16", features = ["kv_unstable_serde"] }
|
||||||
ordered-float = { version = "2.1.1" }
|
ordered-float = { version = "2.1.1" }
|
||||||
|
|
|
@ -4,9 +4,6 @@ version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[lib]
|
|
||||||
path = "src/cli.rs"
|
|
||||||
doctest = false
|
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "cli"
|
name = "cli"
|
||||||
|
@ -20,6 +17,7 @@ ipc-channel = "0.16"
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
serde_derive.workspace = true
|
serde_derive.workspace = true
|
||||||
util = { path = "../util" }
|
util = { path = "../util" }
|
||||||
|
cli_rpc = {path = "../cli_rpc"}
|
||||||
|
|
||||||
[target.'cfg(target_os = "macos")'.dependencies]
|
[target.'cfg(target_os = "macos")'.dependencies]
|
||||||
core-foundation = "0.9"
|
core-foundation = "0.9"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use cli::{CliRequest, CliResponse, IpcHandshake, FORCE_CLI_MODE_ENV_VAR_NAME};
|
use cli_rpc::{CliRequest, CliResponse, IpcHandshake, FORCE_CLI_MODE_ENV_VAR_NAME};
|
||||||
use core_foundation::{
|
use core_foundation::{
|
||||||
array::{CFArray, CFIndex},
|
array::{CFArray, CFIndex},
|
||||||
string::kCFStringEncodingUTF8,
|
string::kCFStringEncodingUTF8,
|
||||||
|
|
11
crates/cli_rpc/Cargo.toml
Normal file
11
crates/cli_rpc/Cargo.toml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
[package]
|
||||||
|
name = "cli_rpc"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
ipc-channel = "0.16"
|
||||||
|
serde.workspace = true
|
||||||
|
serde_derive.workspace = true
|
|
@ -20,7 +20,7 @@ activity_indicator = { path = "../activity_indicator" }
|
||||||
auto_update = { path = "../auto_update" }
|
auto_update = { path = "../auto_update" }
|
||||||
breadcrumbs = { path = "../breadcrumbs" }
|
breadcrumbs = { path = "../breadcrumbs" }
|
||||||
call = { path = "../call" }
|
call = { path = "../call" }
|
||||||
cli = { path = "../cli" }
|
cli_rpc = { path = "../cli_rpc" }
|
||||||
collab_ui = { path = "../collab_ui" }
|
collab_ui = { path = "../collab_ui" }
|
||||||
collections = { path = "../collections" }
|
collections = { path = "../collections" }
|
||||||
command_palette = { path = "../command_palette" }
|
command_palette = { path = "../command_palette" }
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
use backtrace::Backtrace;
|
use backtrace::Backtrace;
|
||||||
use cli::{
|
use cli_rpc::{
|
||||||
ipc::{self, IpcSender},
|
ipc::{self, IpcSender},
|
||||||
CliRequest, CliResponse, IpcHandshake, FORCE_CLI_MODE_ENV_VAR_NAME,
|
CliRequest, CliResponse, IpcHandshake, FORCE_CLI_MODE_ENV_VAR_NAME,
|
||||||
};
|
};
|
||||||
|
@ -67,7 +67,8 @@ fn main() {
|
||||||
|
|
||||||
log::info!("========== starting zed ==========");
|
log::info!("========== starting zed ==========");
|
||||||
let platform = platform();
|
let platform = platform();
|
||||||
let foreground = std::rc::Rc::new(gpui::executor::Foreground::platform(platform.dispatcher()).unwrap());
|
let foreground =
|
||||||
|
std::rc::Rc::new(gpui::executor::Foreground::platform(platform.dispatcher()).unwrap());
|
||||||
let fplatform = foreground_platform(foreground);
|
let fplatform = foreground_platform(foreground);
|
||||||
let mut app = gpui::App::new(Assets, platform, fplatform).unwrap();
|
let mut app = gpui::App::new(Assets, platform, fplatform).unwrap();
|
||||||
|
|
||||||
|
@ -666,7 +667,7 @@ async fn watch_languages(_: Arc<dyn Fs>, _: Arc<LanguageRegistry>) -> Option<()>
|
||||||
fn connect_to_cli(
|
fn connect_to_cli(
|
||||||
server_name: &str,
|
server_name: &str,
|
||||||
) -> Result<(mpsc::Receiver<CliRequest>, IpcSender<CliResponse>)> {
|
) -> Result<(mpsc::Receiver<CliRequest>, IpcSender<CliResponse>)> {
|
||||||
let handshake_tx = cli::ipc::IpcSender::<IpcHandshake>::connect(server_name.to_string())
|
let handshake_tx = cli_rpc::ipc::IpcSender::<IpcHandshake>::connect(server_name.to_string())
|
||||||
.context("error connecting to cli")?;
|
.context("error connecting to cli")?;
|
||||||
let (request_tx, request_rx) = ipc::channel::<CliRequest>()?;
|
let (request_tx, request_rx) = ipc::channel::<CliRequest>()?;
|
||||||
let (response_tx, response_rx) = ipc::channel::<CliResponse>()?;
|
let (response_tx, response_rx) = ipc::channel::<CliResponse>()?;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue