From db0aaeca33d430de00587958f82844f088d84a30 Mon Sep 17 00:00:00 2001 From: kjeremy Date: Tue, 19 Jan 2021 11:56:45 -0500 Subject: Update pico-args Should maintains existing behavior --- xtask/Cargo.toml | 2 +- xtask/src/main.rs | 34 +++++++++++++++++++++------------- 2 files changed, 22 insertions(+), 14 deletions(-) (limited to 'xtask') diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index 4abc7b053..4e6b439fd 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -12,7 +12,7 @@ doctest = false [dependencies] anyhow = "1.0.26" flate2 = "1.0" -pico-args = "0.3.1" +pico-args = "0.4.0" proc-macro2 = "1.0.8" quote = "1.0.2" ungrammar = "1.9" diff --git a/xtask/src/main.rs b/xtask/src/main.rs index c3e5c7326..5a99f4a76 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -10,6 +10,7 @@ use std::env; +use anyhow::bail; use codegen::CodegenCmd; use pico_args::Arguments; use xshell::{cmd, cp, pushd}; @@ -76,7 +77,7 @@ FLAGS: let client_opt = args.opt_value_from_str("--client")?; - args.finish()?; + finish_args(args)?; InstallCmd { client: if server { None } else { Some(client_opt.unwrap_or_default()) }, @@ -86,53 +87,53 @@ FLAGS: } "codegen" => { let features = args.contains("--features"); - args.finish()?; + finish_args(args)?; CodegenCmd { features }.run() } "format" => { - args.finish()?; + finish_args(args)?; run_rustfmt(Mode::Overwrite) } "install-pre-commit-hook" => { - args.finish()?; + finish_args(args)?; pre_commit::install_hook() } "lint" => { - args.finish()?; + finish_args(args)?; run_clippy() } "fuzz-tests" => { - args.finish()?; + finish_args(args)?; run_fuzzer() } "pre-cache" => { - args.finish()?; + finish_args(args)?; PreCacheCmd.run() } "release" => { let dry_run = args.contains("--dry-run"); - args.finish()?; + finish_args(args)?; ReleaseCmd { dry_run }.run() } "promote" => { let dry_run = args.contains("--dry-run"); - args.finish()?; + finish_args(args)?; PromoteCmd { dry_run }.run() } "dist" => { let nightly = args.contains("--nightly"); let client_version: Option = args.opt_value_from_str("--client")?; - args.finish()?; + finish_args(args)?; DistCmd { nightly, client_version }.run() } "metrics" => { let dry_run = args.contains("--dry-run"); - args.finish()?; + finish_args(args)?; MetricsCmd { dry_run }.run() } "bb" => { - let suffix: String = args.free_from_str()?.unwrap(); - args.finish()?; + let suffix: String = args.free_from_str()?; + finish_args(args)?; cmd!("cargo build --release").run()?; cp("./target/release/rust-analyzer", format!("./target/rust-analyzer-{}", suffix))?; Ok(()) @@ -161,3 +162,10 @@ SUBCOMMANDS: } } } + +fn finish_args(args: Arguments) -> Result<()> { + if !args.finish().is_empty() { + bail!("Unused arguments."); + } + Ok(()) +} -- cgit v1.2.3