-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(lsp): handle CLI args for different communication channels
Implement handling of the common CLI arguments that define how to establish the client/server communication channel. The options are defined, but not all are supported as of yet.
- Loading branch information
Showing
7 changed files
with
71 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use std::path::PathBuf; | ||
|
||
use clap::{Parser, ValueHint}; | ||
|
||
#[derive(Parser)] | ||
#[command(about, author, version)] | ||
pub struct Cli { | ||
/// Use standard I/O as the communication channel. | ||
#[arg(long, conflicts_with_all = ["pipe", "socket"])] | ||
pub stdio: bool, | ||
/// Use pipes (Windows) or socket files (Linux, Mac) as the communication channel. | ||
#[arg( | ||
long, | ||
conflicts_with_all = ["socket"], | ||
value_name = "FILE", | ||
value_hint = ValueHint::FilePath, | ||
)] | ||
pub pipe: Option<PathBuf>, | ||
/// Use a socket as the communication channel. | ||
#[arg(long, exclusive = true, value_name = "PORT")] | ||
pub socket: Option<u16>, | ||
/// Process ID of the editor that started this server. | ||
/// | ||
/// To support the case that the editor starting a server crashes an editor should also pass | ||
/// its process id to the server. This allows the server to monitor the editor process and to | ||
/// shutdown itself if the editor process dies. | ||
#[arg(long = "clientProcessId", value_name = "ID")] | ||
pub client_process_id: Option<i32>, | ||
} | ||
|
||
impl Cli { | ||
pub fn parse() -> Self { | ||
<Self as Parser>::parse() | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::Cli; | ||
|
||
#[test] | ||
fn verify_cli() { | ||
use clap::CommandFactory; | ||
Cli::command().debug_assert(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters