Skip to content

Commit 855b7e8

Browse files
committed
jsondoclint: Add --verbose flag.
Without verbose: 0:61941:36627 not in index or paths, but refered to at '$.index["0:62007"].inner.for.inner.id' and 12 more With verbose: 0:10808:27206 not in index or paths, but refered to at '$.index["0:10813"].inner.for.inner.id', '$.index["0:52495"].inner.for.inner.id', '$.index["a:0:2666:215-0:10808:27206"].inner.for.inner.id', '$.index["a:0:2680:223-0:10808:27206"].inner.for.inner.id', '$.index["a:0:2730:7845-0:10808:27206"].inner.for.inner.id', '$.index["a:0:7731:21706-0:10808:27206"].inner.for.inner.id', '$.index["a:0:7732:21705-0:10808:27206"].inner.for.inner.id'
1 parent 7680b16 commit 855b7e8

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

src/tools/jsondoclint/src/main.rs

+26-6
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@ enum ErrorKind {
2424
struct Cli {
2525
/// The path to the json file to be linted
2626
path: String,
27+
28+
/// Show verbose output
29+
#[arg(long)]
30+
verbose: bool,
2731
}
2832

2933
fn main() -> Result<()> {
30-
let Cli { path } = Cli::parse();
34+
let Cli { path, verbose } = Cli::parse();
3135

3236
let contents = fs::read_to_string(&path)?;
3337
let krate: Crate = serde_json::from_str(&contents)?;
@@ -53,11 +57,27 @@ fn main() -> Result<()> {
5357
err.id.0,
5458
json_find::to_jsonpath(&sel)
5559
),
56-
[sel, ..] => eprintln!(
57-
"{} not in index or paths, but refered to at '{}' and more",
58-
err.id.0,
59-
json_find::to_jsonpath(&sel)
60-
),
60+
[sel, ..] => {
61+
if verbose {
62+
let sels = sels
63+
.iter()
64+
.map(json_find::to_jsonpath)
65+
.map(|i| format!("'{i}'"))
66+
.collect::<Vec<_>>()
67+
.join(", ");
68+
eprintln!(
69+
"{} not in index or paths, but refered to at {sels}",
70+
err.id.0
71+
);
72+
} else {
73+
eprintln!(
74+
"{} not in index or paths, but refered to at '{}' and {} more",
75+
err.id.0,
76+
json_find::to_jsonpath(&sel),
77+
sels.len() - 1,
78+
)
79+
}
80+
}
6181
}
6282
}
6383
ErrorKind::Custom(msg) => eprintln!("{}: {}", err.id.0, msg),

0 commit comments

Comments
 (0)