Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsondocck small cleanup #85899

Merged
merged 2 commits into from
Jun 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1743,11 +1743,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 @@ -2128,7 +2127,7 @@ dependencies = [
"serde",
"serde_derive",
"serde_json",
"shlex 1.0.0",
"shlex",
"tempfile",
"toml",
]
Expand Down Expand Up @@ -4794,12 +4793,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