File tree Expand file tree Collapse file tree 3 files changed +28
-5
lines changed Expand file tree Collapse file tree 3 files changed +28
-5
lines changed Original file line number Diff line number Diff line change @@ -597,7 +597,7 @@ checksum = "23b71c3ce99b7611011217b366d923f1d0a7e07a92bb2dbf1e84508c673ca3bd"
597
597
dependencies = [
598
598
" atty" ,
599
599
" bitflags" ,
600
- " clap_derive" ,
600
+ " clap_derive 3.2.18 " ,
601
601
" clap_lex 0.2.2" ,
602
602
" indexmap" ,
603
603
" once_cell" ,
@@ -614,7 +614,9 @@ checksum = "6bf8832993da70a4c6d13c581f4463c2bdda27b9bf1c5498dc4365543abe6d6f"
614
614
dependencies = [
615
615
" atty" ,
616
616
" bitflags" ,
617
+ " clap_derive 4.0.13" ,
617
618
" clap_lex 0.3.0" ,
619
+ " once_cell" ,
618
620
" strsim" ,
619
621
" termcolor" ,
620
622
]
@@ -641,6 +643,19 @@ dependencies = [
641
643
" syn" ,
642
644
]
643
645
646
+ [[package ]]
647
+ name = " clap_derive"
648
+ version = " 4.0.13"
649
+ source = " registry+https://github.com/rust-lang/crates.io-index"
650
+ checksum = " c42f169caba89a7d512b5418b09864543eeb4d497416c917d7137863bd2076ad"
651
+ dependencies = [
652
+ " heck" ,
653
+ " proc-macro-error" ,
654
+ " proc-macro2" ,
655
+ " quote" ,
656
+ " syn" ,
657
+ ]
658
+
644
659
[[package ]]
645
660
name = " clap_lex"
646
661
version = " 0.2.2"
@@ -2097,6 +2112,7 @@ name = "jsondoclint"
2097
2112
version = " 0.1.0"
2098
2113
dependencies = [
2099
2114
" anyhow" ,
2115
+ " clap 4.0.15" ,
2100
2116
" fs-err" ,
2101
2117
" rustdoc-json-types" ,
2102
2118
" serde_json" ,
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ edition = "2021"
7
7
8
8
[dependencies ]
9
9
anyhow = " 1.0.62"
10
+ clap = { version = " 4.0.15" , features = [" derive" ] }
10
11
fs-err = " 2.8.1"
11
12
rustdoc-json-types = { version = " 0.1.0" , path = " ../../rustdoc-json-types" }
12
13
serde_json = " 1.0.85"
Original file line number Diff line number Diff line change 1
- use std:: env;
2
-
3
- use anyhow:: { anyhow, bail, Result } ;
1
+ use anyhow:: { bail, Result } ;
2
+ use clap:: Parser ;
4
3
use fs_err as fs;
5
4
use rustdoc_json_types:: { Crate , Id , FORMAT_VERSION } ;
6
5
use serde_json:: Value ;
@@ -21,8 +20,15 @@ enum ErrorKind {
21
20
Custom ( String ) ,
22
21
}
23
22
23
+ #[ derive( Parser ) ]
24
+ struct Cli {
25
+ /// The path to the json file to be linted
26
+ path : String ,
27
+ }
28
+
24
29
fn main ( ) -> Result < ( ) > {
25
- let path = env:: args ( ) . nth ( 1 ) . ok_or_else ( || anyhow ! ( "no path given" ) ) ?;
30
+ let Cli { path } = Cli :: parse ( ) ;
31
+
26
32
let contents = fs:: read_to_string ( & path) ?;
27
33
let krate: Crate = serde_json:: from_str ( & contents) ?;
28
34
assert_eq ! ( krate. format_version, FORMAT_VERSION ) ;
You can’t perform that action at this time.
0 commit comments