rust-analyzer/crates/tools/src/main.rs

55 lines
1.7 KiB
Rust
Raw Normal View History

use clap::{App, SubCommand};
2018-12-06 17:42:03 +00:00
2018-12-31 13:14:06 +00:00
use tools::{
generate, gen_tests, install_format_hook, run, run_rustfmt,
Overwrite, Result, run_fuzzer,
2018-12-31 13:14:06 +00:00
};
2018-07-30 11:06:22 +00:00
fn main() -> Result<()> {
let matches = App::new("tasks")
.setting(clap::AppSettings::SubcommandRequiredElseHelp)
2018-10-16 18:09:22 +00:00
.subcommand(SubCommand::with_name("gen-syntax"))
2018-07-30 11:06:22 +00:00
.subcommand(SubCommand::with_name("gen-tests"))
2018-07-30 19:17:33 +00:00
.subcommand(SubCommand::with_name("install-code"))
2018-10-26 13:08:21 +00:00
.subcommand(SubCommand::with_name("format"))
2018-12-09 10:29:13 +00:00
.subcommand(SubCommand::with_name("format-hook"))
2018-12-31 13:14:06 +00:00
.subcommand(SubCommand::with_name("fuzz-tests"))
2018-07-30 11:06:22 +00:00
.get_matches();
2018-12-09 10:29:13 +00:00
match matches
.subcommand_name()
.expect("Subcommand must be specified")
{
"install-code" => install_code_extension()?,
"gen-tests" => gen_tests(Overwrite)?,
2018-12-09 10:29:13 +00:00
"gen-syntax" => generate(Overwrite)?,
"format" => run_rustfmt(Overwrite)?,
2018-12-09 10:29:13 +00:00
"format-hook" => install_format_hook()?,
2018-12-31 13:14:06 +00:00
"fuzz-tests" => run_fuzzer()?,
2018-07-30 11:06:22 +00:00
_ => unreachable!(),
}
2018-08-09 14:43:39 +00:00
Ok(())
2018-07-30 11:06:22 +00:00
}
2018-07-30 19:17:33 +00:00
fn install_code_extension() -> Result<()> {
2018-09-16 09:54:24 +00:00
run("cargo install --path crates/ra_lsp_server --force", ".")?;
2018-09-15 23:02:25 +00:00
if cfg!(windows) {
2019-01-23 18:23:15 +00:00
run(r"cmd.exe /c npm.cmd ci", "./editors/code")?;
2018-12-17 08:26:41 +00:00
run(r"cmd.exe /c npm.cmd run package", "./editors/code")?;
2018-09-16 00:06:56 +00:00
} else {
2019-01-23 18:23:15 +00:00
run(r"npm ci", "./editors/code")?;
2018-12-17 08:26:41 +00:00
run(r"npm run package", "./editors/code")?;
2018-09-15 23:02:25 +00:00
}
if cfg!(windows) {
run(
2019-01-12 15:00:03 +00:00
r"cmd.exe /c code.cmd --install-extension ./ra-lsp-0.0.1.vsix --force",
"./editors/code",
)?;
2018-09-15 23:02:25 +00:00
} else {
run(
2019-01-12 15:00:03 +00:00
r"code --install-extension ./ra-lsp-0.0.1.vsix --force",
"./editors/code",
)?;
2018-09-15 23:02:25 +00:00
}
2018-09-15 23:12:53 +00:00
Ok(())
}