@@ -12,29 +12,31 @@ mod runtime;
1212shadow_rs:: shadow!( shadow) ;
1313
1414use clap:: Parser ;
15- use cli:: { Command , IoPath , Source } ;
16- use prompt:: YesOrNo ;
17- use runtime:: { CheckerContext , Runtime } ;
18- use thisctx:: WithContext ;
15+ use thisctx:: { IntoError , WithContext } ;
1916use tracing:: { error, info, warn, Level } ;
2017use tracing_subscriber:: prelude:: * ;
21- use util:: { LogStatus , ResultExt as _} ;
2218use walkdir:: WalkDir ;
2319
20+ use self :: cli:: { Command , IoPath , Source } ;
21+ use self :: prompt:: YesOrNo ;
22+ use self :: runtime:: { CheckerContext , Runtime } ;
23+ use self :: util:: { LogStatus , ResultExt as _} ;
24+
2425static ICONS : & str = include_str ! ( "./icons.json" ) ;
2526static SUBSTITUTIONS : & str = include_str ! ( "./substitutions.json" ) ;
2627
2728fn walk < ' a > (
28- paths : impl ' a + IntoIterator < Item = Source > ,
29+ paths : impl ' a + IntoIterator < Item = ( IoPath , Option < IoPath > ) > ,
2930 recursive : bool ,
3031) -> impl ' a + Iterator < Item = error:: Result < Source > > {
3132 if !recursive {
32- Box :: new ( paths. into_iter ( ) . map ( Ok ) ) as Box < dyn Iterator < Item = _ > >
33+ Box :: new ( paths. into_iter ( ) . map ( |( i, o) | Source ( i, o) ) . map ( Ok ) )
34+ as Box < dyn Iterator < Item = _ > >
3335 } else {
3436 Box :: new (
3537 paths
3638 . into_iter ( )
37- . flat_map ( |Source ( input, output) | {
39+ . flat_map ( |( input, output) | {
3840 if let Some ( output) = output {
3941 warn ! ( "Output path is ignored when `--recursive`: {}" , output) ;
4042 }
@@ -58,7 +60,7 @@ fn walk<'a>(
5860 } )
5961 . transpose ( )
6062 } )
61- . map ( |e| e. map ( |path| Source ( IoPath :: Path ( path) , None ) ) ) ,
63+ . map ( |e| e. map ( |path| Source ( IoPath :: Path ( path. try_into ( ) . unwrap ( ) ) , None ) ) ) ,
6264 )
6365 }
6466}
@@ -119,7 +121,7 @@ fn main_impl() -> error::Result<()> {
119121 size_limit : size_limit. as_u64 ( ) ,
120122 ..Default :: default ( )
121123 } ;
122- for source in walk ( source. into_iter ( ) . map ( |p| Source ( p, None ) ) , recursive) {
124+ for source in walk ( source. into_iter ( ) . map ( |p| ( p, None ) ) , recursive) {
123125 tri ! ( {
124126 let source = source?;
125127 rt. check( & mut context, & source. 0 , None )
@@ -135,11 +137,23 @@ fn main_impl() -> error::Result<()> {
135137 recursive,
136138 include_binary,
137139 size_limit,
140+ output,
138141 source,
139142 } => {
140143 if yes {
141144 warn ! ( "`--yes` is deprecated, use `--write` instead" ) ;
142145 }
146+ if !output. is_empty ( ) && output. len ( ) != source. len ( ) {
147+ return Err ( error:: OutputMismatched . build ( ) ) ;
148+ }
149+ if cfg ! ( unix) {
150+ // Colon in `C:\Path` should not be considered as separators.
151+ for p in source. iter ( ) {
152+ if matches ! ( p, IoPath :: Path ( p) if p. as_str( ) . contains( ':' ) ) {
153+ warn ! ( "`input:output` syntax is deprecated, use `--output` instead" ) ;
154+ }
155+ }
156+ }
143157 let rt = rt. build ( ) ;
144158 let mut context = CheckerContext {
145159 write,
@@ -149,7 +163,10 @@ fn main_impl() -> error::Result<()> {
149163 ..Default :: default ( )
150164 } ;
151165 let mut buffer = String :: new ( ) ;
152- for source in walk ( source, recursive) {
166+ for source in walk (
167+ source. into_iter ( ) . zip ( output. into_iter ( ) . map ( |p| p. 0 ) ) ,
168+ recursive,
169+ ) {
153170 tri ! ( {
154171 let source = source?;
155172 let Source ( input, output) = & source;
0 commit comments