1
1
extern crate inflector;
2
+ extern crate log;
3
+ extern crate simplelog;
2
4
3
5
use std:: env;
4
6
use std:: process:: { Command , ExitCode } ;
@@ -7,8 +9,18 @@ use std::path::Path;
7
9
use std:: collections:: HashMap ;
8
10
use std:: process;
9
11
use inflector:: Inflector ;
12
+ use log:: * ;
13
+ use simplelog:: { TermLogger , TerminalMode , ColorChoice , Config } ;
10
14
11
15
fn main ( ) -> ExitCode {
16
+ TermLogger :: init (
17
+ LevelFilter :: Trace ,
18
+ Config :: default ( ) ,
19
+ TerminalMode :: Stdout ,
20
+ ColorChoice :: Auto ,
21
+ )
22
+ . expect ( "Failed to init logger" ) ;
23
+
12
24
let args: Vec < String > = env:: args ( ) . collect ( ) ;
13
25
let chapter = & args[ 1 ] ;
14
26
let unity = & args[ 2 ] ;
@@ -281,6 +293,24 @@ fn copy_files(from: &str, to: &str) {
281
293
println ! ( "Copying files from {}" , from) ;
282
294
for entry in fs:: read_dir ( from) . expect ( "Can't read directory" ) {
283
295
let path = entry. unwrap ( ) . path ( ) ;
296
+
297
+ // Ignore paths starting with '.ignore' and emit warning
298
+ if let Some ( name) = path. file_name ( ) {
299
+ let name = name. to_os_string ( ) ;
300
+ if name. to_string_lossy ( ) . to_lowercase ( ) . starts_with ( ".ignore" )
301
+ {
302
+ warn ! ( "Skipping path {:?} as it starts with '.ignore'" , path) ;
303
+ continue ;
304
+ }
305
+ }
306
+
307
+ // For now, subdirectories are not supported
308
+ if path. is_dir ( )
309
+ {
310
+ error ! ( "Found subdirectory at {:?} - Subdirectories not supported, please remove or prepend with 'IGNORE' to ignore." , path) ;
311
+ panic ! ( "Exiting due to unexpected subdirectory" ) ;
312
+ }
313
+
284
314
let to_path = format ! ( "{}/{}" , to, path. file_name( ) . unwrap( ) . to_str( ) . unwrap( ) ) ;
285
315
println ! ( "Copying File {} -> {}" , path. to_string_lossy( ) , to_path) ;
286
316
fs:: copy ( & path, to_path) . expect ( "Unable to copy" ) ;
0 commit comments