mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
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'
This commit is contained in:
parent
7680b164b0
commit
855b7e8cf3
@ -24,10 +24,14 @@ enum ErrorKind {
|
||||
struct Cli {
|
||||
/// The path to the json file to be linted
|
||||
path: String,
|
||||
|
||||
/// Show verbose output
|
||||
#[arg(long)]
|
||||
verbose: bool,
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let Cli { path } = Cli::parse();
|
||||
let Cli { path, verbose } = Cli::parse();
|
||||
|
||||
let contents = fs::read_to_string(&path)?;
|
||||
let krate: Crate = serde_json::from_str(&contents)?;
|
||||
@ -53,11 +57,27 @@ fn main() -> Result<()> {
|
||||
err.id.0,
|
||||
json_find::to_jsonpath(&sel)
|
||||
),
|
||||
[sel, ..] => eprintln!(
|
||||
"{} not in index or paths, but refered to at '{}' and more",
|
||||
err.id.0,
|
||||
json_find::to_jsonpath(&sel)
|
||||
),
|
||||
[sel, ..] => {
|
||||
if verbose {
|
||||
let sels = sels
|
||||
.iter()
|
||||
.map(json_find::to_jsonpath)
|
||||
.map(|i| format!("'{i}'"))
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ");
|
||||
eprintln!(
|
||||
"{} not in index or paths, but refered to at {sels}",
|
||||
err.id.0
|
||||
);
|
||||
} else {
|
||||
eprintln!(
|
||||
"{} not in index or paths, but refered to at '{}' and {} more",
|
||||
err.id.0,
|
||||
json_find::to_jsonpath(&sel),
|
||||
sels.len() - 1,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ErrorKind::Custom(msg) => eprintln!("{}: {}", err.id.0, msg),
|
||||
|
Loading…
Reference in New Issue
Block a user