@@ -29,7 +29,12 @@ fn main() {
29
29
let compile_parameters: Result < CompileParameters , ParameterError > =
30
30
CompileParameters :: parse ( args) ;
31
31
match compile_parameters {
32
- Ok ( cp) => main_compile ( cp) ,
32
+ Ok ( cp) => {
33
+ if let Err ( msg) = main_compile ( cp) {
34
+ println ! ( "Error: {}" , msg) ;
35
+ std:: process:: exit ( 1 ) ;
36
+ }
37
+ }
33
38
Err ( err) => err. exit ( ) , // prints the nice message to std-out
34
39
}
35
40
}
@@ -40,18 +45,23 @@ fn create_file_paths(inputs: &[String]) -> Result<Vec<FilePath>, String> {
40
45
let paths =
41
46
glob ( input) . map_err ( |e| format ! ( "Failed to read glob pattern: {}, ({})" , input, e) ) ?;
42
47
48
+ let source_count_before = sources. len ( ) ;
43
49
for p in paths {
44
50
let path = p. map_err ( |err| format ! ( "Illegal path: {:}" , err) ) ?;
45
51
sources. push ( FilePath {
46
52
path : path. to_string_lossy ( ) . to_string ( ) ,
47
53
} ) ;
48
54
}
55
+
56
+ if sources. len ( ) <= source_count_before {
57
+ return Err ( format ! ( "No such file(s): {}" , input) ) ;
58
+ }
49
59
}
50
60
Ok ( sources)
51
61
}
52
62
53
- fn main_compile ( parameters : CompileParameters ) {
54
- let sources = create_file_paths ( & parameters. input ) . unwrap ( ) ;
63
+ fn main_compile ( parameters : CompileParameters ) -> Result < ( ) , String > {
64
+ let sources = create_file_paths ( & parameters. input ) ? ;
55
65
56
66
let output_filename = parameters. output_name ( ) . unwrap ( ) ;
57
67
let encoding = parameters. encoding ;
@@ -82,4 +92,5 @@ fn main_compile(parameters: CompileParameters) {
82
92
compile_to_ir ( sources, encoding, & output_filename) . unwrap ( ) ;
83
93
}
84
94
}
95
+ Ok ( ( ) )
85
96
}
0 commit comments