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"
597597dependencies  = [
598598 " atty"  ,
599599 " bitflags"  ,
600-  " clap_derive"  ,
600+  " clap_derive 3.2.18 "  ,
601601 " clap_lex 0.2.2"  ,
602602 " indexmap"  ,
603603 " once_cell"  ,
@@ -614,7 +614,9 @@ checksum = "6bf8832993da70a4c6d13c581f4463c2bdda27b9bf1c5498dc4365543abe6d6f"
614614dependencies  = [
615615 " atty"  ,
616616 " bitflags"  ,
617+  " clap_derive 4.0.13"  ,
617618 " clap_lex 0.3.0"  ,
619+  " once_cell"  ,
618620 " strsim"  ,
619621 " termcolor"  ,
620622]
@@ -641,6 +643,19 @@ dependencies = [
641643 " syn"  ,
642644]
643645
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+ 
644659[[package ]]
645660name  = " clap_lex" 
646661version  = " 0.2.2" 
@@ -2097,6 +2112,7 @@ name = "jsondoclint"
20972112version  = " 0.1.0" 
20982113dependencies  = [
20992114 " anyhow"  ,
2115+  " clap 4.0.15"  ,
21002116 " fs-err"  ,
21012117 " rustdoc-json-types"  ,
21022118 " serde_json"  ,
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ edition = "2021"
77
88[dependencies ]
99anyhow  = " 1.0.62" 
10+ clap  = { version  = " 4.0.15"  , features  = [" derive"  ] }
1011fs-err  = " 2.8.1" 
1112rustdoc-json-types  = { version  = " 0.1.0"  , path  = " ../../rustdoc-json-types"   }
1213serde_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 ; 
43use  fs_err as  fs; 
54use  rustdoc_json_types:: { Crate ,  Id ,  FORMAT_VERSION } ; 
65use  serde_json:: Value ; 
@@ -21,8 +20,15 @@ enum ErrorKind {
2120    Custom ( String ) , 
2221} 
2322
23+ #[ derive( Parser ) ]  
24+ struct  Cli  { 
25+     /// The path to the json file to be linted 
26+      path :  String , 
27+ } 
28+ 
2429fn  main ( )  -> Result < ( ) >  { 
25-     let  path = env:: args ( ) . nth ( 1 ) . ok_or_else ( || anyhow ! ( "no path given" ) ) ?; 
30+     let  Cli  {  path }  = Cli :: parse ( ) ; 
31+ 
2632    let  contents = fs:: read_to_string ( & path) ?; 
2733    let  krate:  Crate  = serde_json:: from_str ( & contents) ?; 
2834    assert_eq ! ( krate. format_version,  FORMAT_VERSION ) ; 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments