jsona_cli/commands/
lsp.rs1use crate::App;
2
3use clap::Subcommand;
4use jsona_util::environment::{native::NativeEnvironment, Environment};
5
6impl<E: Environment> App<E> {
7 pub async fn execute_lsp(&self, cmd: LspCommand) -> Result<(), anyhow::Error> {
8 let server = jsona_lsp::create_server();
9 let world = jsona_lsp::create_world(NativeEnvironment::new());
10
11 match cmd {
12 LspCommand::Tcp { address } => {
13 server
14 .listen_tcp(world, &address, async_ctrlc::CtrlC::new().unwrap())
15 .await
16 }
17 LspCommand::Stdio {} => {
18 server
19 .listen_stdio(world, async_ctrlc::CtrlC::new().unwrap())
20 .await
21 }
22 }
23 }
24}
25
26#[derive(Debug, Clone, Subcommand)]
27pub enum LspCommand {
28 Tcp {
30 #[clap(long, default_value = "0.0.0.0:9182")]
32 address: String,
33 },
34 Stdio {},
36}