File tree 4 files changed +12
-12
lines changed
4 files changed +12
-12
lines changed Original file line number Diff line number Diff line change 1
- use std :: process ;
1
+ use crate :: ErrorMessage ;
2
2
3
3
const HELP : & str = include_str ! ( "help.txt" ) ;
4
4
const BUILD_HELP : & str = include_str ! ( "build_help.txt" ) ;
@@ -31,9 +31,7 @@ pub(crate) fn test_help() {
31
31
print ! ( "{}" , TEST_HELP ) ;
32
32
}
33
33
34
- pub ( crate ) fn no_subcommand ( ) -> ! {
35
- println ! ( "Please invoke `bootimage` with a subcommand (e.g. `bootimage build`)." ) ;
36
- println ! ( ) ;
37
- println ! ( "See `bootimage --help` for more information." ) ;
38
- process:: exit ( 1 ) ;
34
+ pub ( crate ) fn no_subcommand ( ) -> ErrorMessage {
35
+ "Please invoke `bootimage` with a subcommand (e.g. `bootimage build`).\n \n \
36
+ See `bootimage --help` for more information.". into ( )
39
37
}
Original file line number Diff line number Diff line change @@ -64,14 +64,14 @@ pub fn run() -> Result<Option<i32>, ErrorMessage> {
64
64
Command :: Run ( args) => subcommand:: run:: run ( args) . map ( Some ) ,
65
65
Command :: Test ( args) => subcommand:: test:: test ( args) . map ( none) ,
66
66
Command :: Runner ( args) => subcommand:: runner:: runner ( args) . map ( Some ) ,
67
- Command :: NoSubcommand => help:: no_subcommand ( ) ,
68
67
Command :: Help => Ok ( help:: help ( ) ) . map ( none) ,
69
68
Command :: BuildHelp => Ok ( help:: build_help ( ) ) . map ( none) ,
70
69
Command :: CargoBootimageHelp => Ok ( help:: cargo_bootimage_help ( ) ) . map ( none) ,
71
70
Command :: RunHelp => Ok ( help:: run_help ( ) ) . map ( none) ,
72
71
Command :: RunnerHelp => Ok ( help:: runner_help ( ) ) . map ( none) ,
73
72
Command :: TestHelp => Ok ( help:: test_help ( ) ) . map ( none) ,
74
73
Command :: Version => Ok ( println ! ( "bootimage {}" , env!( "CARGO_PKG_VERSION" ) ) ) . map ( none) ,
74
+ Command :: NoSubcommand => Err ( help:: no_subcommand ( ) ) ,
75
75
}
76
76
}
77
77
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ pub(crate) fn build_impl(
15
15
args : & Args ,
16
16
quiet : bool ,
17
17
) -> Result < Vec < PathBuf > , ErrorMessage > {
18
- run_cargo_fetch ( & args) ;
18
+ run_cargo_fetch ( & args) . map_err ( | ( ) | "cargo fetch failed" ) ? ;
19
19
20
20
let executables = builder. build_kernel ( & args. cargo_args , quiet) ?;
21
21
if executables. len ( ) == 0 {
@@ -40,14 +40,16 @@ pub(crate) fn build_impl(
40
40
Ok ( bootimages)
41
41
}
42
42
43
- fn run_cargo_fetch ( args : & Args ) {
43
+ fn run_cargo_fetch ( args : & Args ) -> Result < ( ) , ( ) > {
44
44
let mut command = process:: Command :: new ( "cargo" ) ;
45
45
command. arg ( "fetch" ) ;
46
46
if let Some ( manifest_path) = args. manifest_path ( ) {
47
47
command. arg ( "--manifest-path" ) ;
48
48
command. arg ( manifest_path) ;
49
49
}
50
- if !command. status ( ) . map ( |s| s. success ( ) ) . unwrap_or ( false ) {
51
- process:: exit ( 1 ) ;
50
+ if command. status ( ) . map ( |s| s. success ( ) ) . unwrap_or ( false ) {
51
+ Ok ( ( ) )
52
+ } else {
53
+ Err ( ( ) )
52
54
}
53
55
}
Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ pub(crate) fn test(mut args: Args) -> Result<(), ErrorMessage> {
94
94
for test in tests. iter ( ) . filter ( |t| t. 1 != TestResult :: Ok ) {
95
95
writeln ! ( io:: stderr( ) , " {}: {:?}" , test. 0 , test. 1 ) ?;
96
96
}
97
- process :: exit ( 1 ) ;
97
+ Err ( "Some tests failed" . into ( ) )
98
98
}
99
99
}
100
100
You can’t perform that action at this time.
0 commit comments