Skip to content

Commit

Permalink
Rollup merge of #85899 - klensy:jsondocck-f, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
jsondocck small cleanup

updated `shlex` (there was some fix comex/rust-shlex@6db4704)
replaced `lazy_static` with `once_cell`
removed `serde` direct dependency (`serde_json` will pull it)
  • Loading branch information
JohnTitor authored Jun 4, 2021
2 parents 3500e76 + 5afc594 commit 5b0a49e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
13 changes: 3 additions & 10 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1753,11 +1753,10 @@ dependencies = [
"fs-err",
"getopts",
"jsonpath_lib",
"lazy_static",
"once_cell",
"regex",
"serde",
"serde_json",
"shlex 0.1.1",
"shlex",
]

[[package]]
Expand Down Expand Up @@ -2138,7 +2137,7 @@ dependencies = [
"serde",
"serde_derive",
"serde_json",
"shlex 1.0.0",
"shlex",
"tempfile",
"toml",
]
Expand Down Expand Up @@ -4813,12 +4812,6 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45bb67a18fa91266cc7807181f62f9178a6873bfad7dc788c42e6430db40184f"

[[package]]
name = "shlex"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2"

[[package]]
name = "shlex"
version = "1.0.0"
Expand Down
5 changes: 2 additions & 3 deletions src/tools/jsondocck/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ edition = "2018"
jsonpath_lib = "0.2"
getopts = "0.2"
regex = "1.4"
lazy_static = "1.4"
shlex = "0.1"
serde = "1.0"
shlex = "1.0"
serde_json = "1.0"
fs-err = "2.5.0"
once_cell = "1.0"
12 changes: 6 additions & 6 deletions src/tools/jsondocck/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use jsonpath_lib::select;
use lazy_static::lazy_static;
use once_cell::sync::Lazy;
use regex::{Regex, RegexBuilder};
use serde_json::Value;
use std::borrow::Cow;
Expand Down Expand Up @@ -94,19 +94,19 @@ impl fmt::Display for CommandKind {
}
}

lazy_static! {
static ref LINE_PATTERN: Regex = RegexBuilder::new(
static LINE_PATTERN: Lazy<Regex> = Lazy::new(|| {
RegexBuilder::new(
r#"
\s(?P<invalid>!?)@(?P<negated>!?)
(?P<cmd>[A-Za-z]+(?:-[A-Za-z]+)*)
(?P<args>.*)$
"#
"#,
)
.ignore_whitespace(true)
.unicode(true)
.build()
.unwrap();
}
.unwrap()
});

fn print_err(msg: &str, lineno: usize) {
eprintln!("Invalid command: {} on line {}", msg, lineno)
Expand Down

0 comments on commit 5b0a49e

Please sign in to comment.