mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
Update pico-args
Should maintains existing behavior
This commit is contained in:
parent
02edb4b31b
commit
db0aaeca33
5 changed files with 40 additions and 25 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -1205,9 +1205,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pico-args"
|
name = "pico-args"
|
||||||
version = "0.3.4"
|
version = "0.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "28b9b4df73455c861d7cbf8be42f01d3b373ed7f02e378d55fa84eafc6f638b1"
|
checksum = "d70072c20945e1ab871c472a285fc772aefd4f5407723c206242f2c6f94595d6"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pin-project-lite"
|
name = "pin-project-lite"
|
||||||
|
|
|
@ -24,7 +24,7 @@ jod-thread = "0.1.0"
|
||||||
log = "0.4.8"
|
log = "0.4.8"
|
||||||
lsp-types = { version = "0.86.0", features = ["proposed"] }
|
lsp-types = { version = "0.86.0", features = ["proposed"] }
|
||||||
parking_lot = "0.11.0"
|
parking_lot = "0.11.0"
|
||||||
pico-args = "0.3.1"
|
pico-args = "0.4.0"
|
||||||
oorandom = "11.1.2"
|
oorandom = "11.1.2"
|
||||||
rustc-hash = "1.1.0"
|
rustc-hash = "1.1.0"
|
||||||
serde = { version = "1.0.106", features = ["derive"] }
|
serde = { version = "1.0.106", features = ["derive"] }
|
||||||
|
|
|
@ -109,7 +109,7 @@ impl Args {
|
||||||
let mut matches = Arguments::from_env();
|
let mut matches = Arguments::from_env();
|
||||||
|
|
||||||
if matches.contains("--version") {
|
if matches.contains("--version") {
|
||||||
matches.finish()?;
|
finish_args(matches)?;
|
||||||
return Ok(Args {
|
return Ok(Args {
|
||||||
verbosity: Verbosity::Normal,
|
verbosity: Verbosity::Normal,
|
||||||
log_file: None,
|
log_file: None,
|
||||||
|
@ -143,7 +143,7 @@ impl Args {
|
||||||
let subcommand = match matches.subcommand()? {
|
let subcommand = match matches.subcommand()? {
|
||||||
Some(it) => it,
|
Some(it) => it,
|
||||||
None => {
|
None => {
|
||||||
matches.finish()?;
|
finish_args(matches)?;
|
||||||
return Ok(Args { verbosity, log_file, command: Command::RunServer });
|
return Ok(Args { verbosity, log_file, command: Command::RunServer });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -160,7 +160,7 @@ impl Args {
|
||||||
load_output_dirs: matches.contains("--load-output-dirs"),
|
load_output_dirs: matches.contains("--load-output-dirs"),
|
||||||
with_proc_macro: matches.contains("--with-proc-macro"),
|
with_proc_macro: matches.contains("--with-proc-macro"),
|
||||||
path: matches
|
path: matches
|
||||||
.free_from_str()?
|
.opt_free_from_str()?
|
||||||
.ok_or_else(|| format_err!("expected positional argument"))?,
|
.ok_or_else(|| format_err!("expected positional argument"))?,
|
||||||
}),
|
}),
|
||||||
"analysis-bench" => Command::Bench(BenchCmd {
|
"analysis-bench" => Command::Bench(BenchCmd {
|
||||||
|
@ -187,21 +187,21 @@ impl Args {
|
||||||
load_output_dirs: matches.contains("--load-output-dirs"),
|
load_output_dirs: matches.contains("--load-output-dirs"),
|
||||||
with_proc_macro: matches.contains("--with-proc-macro"),
|
with_proc_macro: matches.contains("--with-proc-macro"),
|
||||||
path: matches
|
path: matches
|
||||||
.free_from_str()?
|
.opt_free_from_str()?
|
||||||
.ok_or_else(|| format_err!("expected positional argument"))?,
|
.ok_or_else(|| format_err!("expected positional argument"))?,
|
||||||
}),
|
}),
|
||||||
"diagnostics" => Command::Diagnostics {
|
"diagnostics" => Command::Diagnostics {
|
||||||
load_output_dirs: matches.contains("--load-output-dirs"),
|
load_output_dirs: matches.contains("--load-output-dirs"),
|
||||||
with_proc_macro: matches.contains("--with-proc-macro"),
|
with_proc_macro: matches.contains("--with-proc-macro"),
|
||||||
path: matches
|
path: matches
|
||||||
.free_from_str()?
|
.opt_free_from_str()?
|
||||||
.ok_or_else(|| format_err!("expected positional argument"))?,
|
.ok_or_else(|| format_err!("expected positional argument"))?,
|
||||||
},
|
},
|
||||||
"proc-macro" => Command::ProcMacro,
|
"proc-macro" => Command::ProcMacro,
|
||||||
"ssr" => Command::Ssr {
|
"ssr" => Command::Ssr {
|
||||||
rules: {
|
rules: {
|
||||||
let mut acc = Vec::new();
|
let mut acc = Vec::new();
|
||||||
while let Some(rule) = matches.free_from_str()? {
|
while let Some(rule) = matches.opt_free_from_str()? {
|
||||||
acc.push(rule);
|
acc.push(rule);
|
||||||
}
|
}
|
||||||
acc
|
acc
|
||||||
|
@ -211,7 +211,7 @@ impl Args {
|
||||||
debug_snippet: matches.opt_value_from_str("--debug")?,
|
debug_snippet: matches.opt_value_from_str("--debug")?,
|
||||||
patterns: {
|
patterns: {
|
||||||
let mut acc = Vec::new();
|
let mut acc = Vec::new();
|
||||||
while let Some(rule) = matches.free_from_str()? {
|
while let Some(rule) = matches.opt_free_from_str()? {
|
||||||
acc.push(rule);
|
acc.push(rule);
|
||||||
}
|
}
|
||||||
acc
|
acc
|
||||||
|
@ -222,7 +222,14 @@ impl Args {
|
||||||
return Ok(Args { verbosity, log_file: None, command: Command::Help });
|
return Ok(Args { verbosity, log_file: None, command: Command::Help });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
matches.finish()?;
|
finish_args(matches)?;
|
||||||
Ok(Args { verbosity, log_file, command })
|
Ok(Args { verbosity, log_file, command })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn finish_args(args: Arguments) -> Result<()> {
|
||||||
|
if !args.finish().is_empty() {
|
||||||
|
bail!("Unused arguments.");
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ doctest = false
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.26"
|
anyhow = "1.0.26"
|
||||||
flate2 = "1.0"
|
flate2 = "1.0"
|
||||||
pico-args = "0.3.1"
|
pico-args = "0.4.0"
|
||||||
proc-macro2 = "1.0.8"
|
proc-macro2 = "1.0.8"
|
||||||
quote = "1.0.2"
|
quote = "1.0.2"
|
||||||
ungrammar = "1.9"
|
ungrammar = "1.9"
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
|
use anyhow::bail;
|
||||||
use codegen::CodegenCmd;
|
use codegen::CodegenCmd;
|
||||||
use pico_args::Arguments;
|
use pico_args::Arguments;
|
||||||
use xshell::{cmd, cp, pushd};
|
use xshell::{cmd, cp, pushd};
|
||||||
|
@ -76,7 +77,7 @@ FLAGS:
|
||||||
|
|
||||||
let client_opt = args.opt_value_from_str("--client")?;
|
let client_opt = args.opt_value_from_str("--client")?;
|
||||||
|
|
||||||
args.finish()?;
|
finish_args(args)?;
|
||||||
|
|
||||||
InstallCmd {
|
InstallCmd {
|
||||||
client: if server { None } else { Some(client_opt.unwrap_or_default()) },
|
client: if server { None } else { Some(client_opt.unwrap_or_default()) },
|
||||||
|
@ -86,53 +87,53 @@ FLAGS:
|
||||||
}
|
}
|
||||||
"codegen" => {
|
"codegen" => {
|
||||||
let features = args.contains("--features");
|
let features = args.contains("--features");
|
||||||
args.finish()?;
|
finish_args(args)?;
|
||||||
CodegenCmd { features }.run()
|
CodegenCmd { features }.run()
|
||||||
}
|
}
|
||||||
"format" => {
|
"format" => {
|
||||||
args.finish()?;
|
finish_args(args)?;
|
||||||
run_rustfmt(Mode::Overwrite)
|
run_rustfmt(Mode::Overwrite)
|
||||||
}
|
}
|
||||||
"install-pre-commit-hook" => {
|
"install-pre-commit-hook" => {
|
||||||
args.finish()?;
|
finish_args(args)?;
|
||||||
pre_commit::install_hook()
|
pre_commit::install_hook()
|
||||||
}
|
}
|
||||||
"lint" => {
|
"lint" => {
|
||||||
args.finish()?;
|
finish_args(args)?;
|
||||||
run_clippy()
|
run_clippy()
|
||||||
}
|
}
|
||||||
"fuzz-tests" => {
|
"fuzz-tests" => {
|
||||||
args.finish()?;
|
finish_args(args)?;
|
||||||
run_fuzzer()
|
run_fuzzer()
|
||||||
}
|
}
|
||||||
"pre-cache" => {
|
"pre-cache" => {
|
||||||
args.finish()?;
|
finish_args(args)?;
|
||||||
PreCacheCmd.run()
|
PreCacheCmd.run()
|
||||||
}
|
}
|
||||||
"release" => {
|
"release" => {
|
||||||
let dry_run = args.contains("--dry-run");
|
let dry_run = args.contains("--dry-run");
|
||||||
args.finish()?;
|
finish_args(args)?;
|
||||||
ReleaseCmd { dry_run }.run()
|
ReleaseCmd { dry_run }.run()
|
||||||
}
|
}
|
||||||
"promote" => {
|
"promote" => {
|
||||||
let dry_run = args.contains("--dry-run");
|
let dry_run = args.contains("--dry-run");
|
||||||
args.finish()?;
|
finish_args(args)?;
|
||||||
PromoteCmd { dry_run }.run()
|
PromoteCmd { dry_run }.run()
|
||||||
}
|
}
|
||||||
"dist" => {
|
"dist" => {
|
||||||
let nightly = args.contains("--nightly");
|
let nightly = args.contains("--nightly");
|
||||||
let client_version: Option<String> = args.opt_value_from_str("--client")?;
|
let client_version: Option<String> = args.opt_value_from_str("--client")?;
|
||||||
args.finish()?;
|
finish_args(args)?;
|
||||||
DistCmd { nightly, client_version }.run()
|
DistCmd { nightly, client_version }.run()
|
||||||
}
|
}
|
||||||
"metrics" => {
|
"metrics" => {
|
||||||
let dry_run = args.contains("--dry-run");
|
let dry_run = args.contains("--dry-run");
|
||||||
args.finish()?;
|
finish_args(args)?;
|
||||||
MetricsCmd { dry_run }.run()
|
MetricsCmd { dry_run }.run()
|
||||||
}
|
}
|
||||||
"bb" => {
|
"bb" => {
|
||||||
let suffix: String = args.free_from_str()?.unwrap();
|
let suffix: String = args.free_from_str()?;
|
||||||
args.finish()?;
|
finish_args(args)?;
|
||||||
cmd!("cargo build --release").run()?;
|
cmd!("cargo build --release").run()?;
|
||||||
cp("./target/release/rust-analyzer", format!("./target/rust-analyzer-{}", suffix))?;
|
cp("./target/release/rust-analyzer", format!("./target/rust-analyzer-{}", suffix))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -161,3 +162,10 @@ SUBCOMMANDS:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn finish_args(args: Arguments) -> Result<()> {
|
||||||
|
if !args.finish().is_empty() {
|
||||||
|
bail!("Unused arguments.");
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue