diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2020-12-07 21:46:39 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-07 21:46:39 +1100 |
commit | 301d3e4b6849d24154ac2d65c00a9b30223d000e (patch) | |
tree | ab3bc074493e6c9be8d1875233bc141bdc0da3b4 /cli/flags.rs | |
parent | c8e9b2654ec0d54c77bb3f49fa31c3986203d517 (diff) |
feat: add mvp language server (#8515)
Resolves #8400
Diffstat (limited to 'cli/flags.rs')
-rw-r--r-- | cli/flags.rs | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/cli/flags.rs b/cli/flags.rs index 5ff21971d..2210d7565 100644 --- a/cli/flags.rs +++ b/cli/flags.rs @@ -17,6 +17,9 @@ pub enum DenoSubcommand { source_file: String, out_file: Option<PathBuf>, }, + Cache { + files: Vec<String>, + }, Compile { source_file: String, output: Option<PathBuf>, @@ -35,9 +38,6 @@ pub enum DenoSubcommand { code: String, as_typescript: bool, }, - Cache { - files: Vec<String>, - }, Fmt { check: bool, files: Vec<PathBuf>, @@ -54,6 +54,7 @@ pub enum DenoSubcommand { root: Option<PathBuf>, force: bool, }, + LanguageServer, Lint { files: Vec<PathBuf>, ignore: Vec<PathBuf>, @@ -293,6 +294,8 @@ pub fn flags_from_vec_safe(args: Vec<String>) -> clap::Result<Flags> { lint_parse(&mut flags, m); } else if let Some(m) = matches.subcommand_matches("compile") { compile_parse(&mut flags, m); + } else if let Some(m) = matches.subcommand_matches("lsp") { + language_server_parse(&mut flags, m); } else { repl_parse(&mut flags, &matches); } @@ -349,6 +352,7 @@ If the flag is set, restrict these messages to errors.", .subcommand(fmt_subcommand()) .subcommand(info_subcommand()) .subcommand(install_subcommand()) + .subcommand(language_server_subcommand()) .subcommand(lint_subcommand()) .subcommand(repl_subcommand()) .subcommand(run_subcommand()) @@ -685,6 +689,10 @@ fn doc_parse(flags: &mut Flags, matches: &clap::ArgMatches) { }; } +fn language_server_parse(flags: &mut Flags, _matches: &clap::ArgMatches) { + flags.subcommand = DenoSubcommand::LanguageServer; +} + fn lint_parse(flags: &mut Flags, matches: &clap::ArgMatches) { let files = match matches.values_of("files") { Some(f) => f.map(PathBuf::from).collect(), @@ -1076,6 +1084,18 @@ Show documentation for runtime built-ins: ) } +fn language_server_subcommand<'a, 'b>() -> App<'a, 'b> { + SubCommand::with_name("lsp") + .setting(AppSettings::Hidden) + .about("Start the language server") + .long_about( + r#"Start the Deno language server which will take input +from stdin and provide output to stdout. + deno lsp +"#, + ) +} + fn lint_subcommand<'a, 'b>() -> App<'a, 'b> { SubCommand::with_name("lint") .about("Lint source files") @@ -1953,6 +1973,18 @@ mod tests { } #[test] + fn language_server() { + let r = flags_from_vec_safe(svec!["deno", "lsp"]); + assert_eq!( + r.unwrap(), + Flags { + subcommand: DenoSubcommand::LanguageServer, + ..Flags::default() + } + ); + } + + #[test] fn lint() { let r = flags_from_vec_safe(svec![ "deno", |