chore: use lsp to get parent process id (#11083)

Removes the previously added internal `--parent-pid` flag. This solution is better.
This commit is contained in:
David Sherret 2021-06-22 21:48:01 -04:00 committed by GitHub
parent 02f7a52235
commit 477273085f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 52 deletions

View file

@ -84,9 +84,7 @@ pub enum DenoSubcommand {
root: Option<PathBuf>,
force: bool,
},
Lsp {
parent_pid: Option<u32>,
},
Lsp,
Lint {
files: Vec<PathBuf>,
ignore: Vec<PathBuf>,
@ -878,16 +876,6 @@ go-to-definition support and automatic code formatting.
How to connect various editors and IDEs to 'deno lsp':
https://deno.land/manual/getting_started/setup_your_environment#editors-and-ides")
.arg(
Arg::with_name("parent-pid")
.long("parent-pid")
.help("The parent process id to periodically check for the existence of or exit")
.takes_value(true)
.validator(|val: String| match val.parse::<usize>() {
Ok(_) => Ok(()),
Err(_) => Err("parent-pid should be a number".to_string()),
}),
)
}
fn lint_subcommand<'a, 'b>() -> App<'a, 'b> {
@ -1633,11 +1621,8 @@ fn install_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
};
}
fn lsp_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
let parent_pid = matches
.value_of("parent-pid")
.map(|val| val.parse().unwrap());
flags.subcommand = DenoSubcommand::Lsp { parent_pid };
fn lsp_parse(flags: &mut Flags, _matches: &clap::ArgMatches) {
flags.subcommand = DenoSubcommand::Lsp;
}
fn lint_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
@ -2317,32 +2302,6 @@ mod tests {
);
}
#[test]
fn lsp() {
let r = flags_from_vec(svec!["deno", "lsp"]);
assert_eq!(
r.unwrap(),
Flags {
subcommand: DenoSubcommand::Lsp { parent_pid: None },
..Flags::default()
}
);
let r = flags_from_vec(svec!["deno", "lsp", "--parent-pid", "5"]);
assert_eq!(
r.unwrap(),
Flags {
subcommand: DenoSubcommand::Lsp {
parent_pid: Some(5),
},
..Flags::default()
}
);
let r = flags_from_vec(svec!["deno", "lsp", "--parent-pid", "invalid-arg"]);
assert!(r.is_err());
}
#[test]
fn lint() {
let r = flags_from_vec(svec!["deno", "lint", "script_1.ts", "script_2.ts"]);