1
1
extern crate inflector;
2
2
3
3
use std:: env;
4
- use std:: process:: Command ;
4
+ use std:: process:: { Command , ExitCode } ;
5
5
use std:: fs;
6
6
use std:: path:: Path ;
7
7
use std:: collections:: HashMap ;
8
8
use std:: process;
9
9
use inflector:: Inflector ;
10
10
11
- fn main ( ) {
11
+ fn main ( ) -> ExitCode {
12
12
let args: Vec < String > = env:: args ( ) . collect ( ) ;
13
13
let chapter = & args[ 1 ] ;
14
14
let unity = & args[ 2 ] ;
@@ -19,6 +19,19 @@ fn main() {
19
19
None
20
20
} ;
21
21
22
+ // Check if python is correctly installed
23
+ println ! ( "Running 'python --version' to check if python is correctly installed..." ) ;
24
+ let result = Command :: new ( "python" )
25
+ . arg ( "--version" )
26
+ . status ( )
27
+ . expect ( "Failed to run python" ) ;
28
+
29
+ if !result. success ( )
30
+ {
31
+ println ! ( "Failed to run python: {:?}" , result) ;
32
+ return ExitCode :: FAILURE ;
33
+ }
34
+
22
35
let mut chapters = HashMap :: new ( ) ;
23
36
chapters. insert ( "onikakushi" , 1 ) ;
24
37
chapters. insert ( "watanagashi" , 2 ) ;
@@ -32,7 +45,6 @@ fn main() {
32
45
33
46
if !chapters. contains_key ( & chapter[ ..] ) {
34
47
println ! ( "Unknown chapter, should be one of {:?}" , chapters. keys( ) ) ;
35
- process:: exit ( 1 ) ;
36
48
}
37
49
38
50
let arc_number = chapters. get ( & chapter[ ..] ) . unwrap ( ) . clone ( ) ;
@@ -68,6 +80,8 @@ fn main() {
68
80
. output ( )
69
81
. expect ( "failed to execute UnityTextModifier.py" ) ;
70
82
83
+ assert ! ( output. status. success( ) ) ;
84
+
71
85
let version = String :: from_utf8_lossy ( & output. stdout ) . into_owned ( ) ;
72
86
73
87
if unity != & version. trim ( ) {
@@ -220,6 +234,8 @@ fn main() {
220
234
let exit_status = status. expect ( "failed to execute 7za or 7z" ) ;
221
235
222
236
assert ! ( exit_status. success( ) ) ;
237
+
238
+ return ExitCode :: SUCCESS ;
223
239
}
224
240
225
241
fn format_checksum ( checksum : Option < & String > , sep : & str ) -> String
0 commit comments