File tree Expand file tree Collapse file tree 3 files changed +29
-5
lines changed Expand file tree Collapse file tree 3 files changed +29
-5
lines changed Original file line number Diff line number Diff line change @@ -26,17 +26,35 @@ fn main() {
26
26
args. next ( ) . unwrap ( ) ;
27
27
}
28
28
29
+ let args: Vec < _ > = args. collect ( ) ;
30
+
31
+ if args. contains ( & "--help" . to_owned ( ) ) {
32
+ print_help ( ) ;
33
+ return ;
34
+ }
35
+
29
36
let workspace_root = workspace_root ( ) ;
30
37
31
38
let build_args = BuildArgs {
32
39
program : env:: var ( "CARGO" ) . expect ( "Missing $CARGO var" ) ,
33
- args : args . collect ( ) ,
40
+ args,
34
41
workspace_root,
35
42
} ;
36
43
37
44
cargo_src:: run_server ( build_args) ;
38
45
}
39
46
47
+ fn print_help ( ) {
48
+ println ! ( "cargo-src" ) ;
49
+ println ! ( "Browse a program's source code\n " ) ;
50
+ println ! ( "USAGE:" ) ;
51
+ println ! ( " cargo src [OPTIONS]\n " ) ;
52
+ println ! ( "OPTIONS:" ) ;
53
+ println ! ( " --help show this message" ) ;
54
+ println ! ( " --open open the cargo-src frontend in your web browser" ) ;
55
+ println ! ( "\n Other options follow `cargo check`, see `cargo check --help` for more." ) ;
56
+ }
57
+
40
58
fn workspace_root ( ) -> String {
41
59
let output = Command :: new ( "cargo" ) . args ( & [ "metadata" , "--format-version" , "1" ] ) . output ( ) ;
42
60
let stdout = String :: from_utf8 ( output. expect ( "error executing `cargo metadata`" ) . stdout ) . expect ( "unexpected output" ) ;
Original file line number Diff line number Diff line change @@ -54,8 +54,11 @@ impl Builder {
54
54
pub fn build ( & self ) -> Option < i32 > {
55
55
let mut cmd = self . init_cmd ( ) ;
56
56
let status = cmd. status ( ) . expect ( "Running build failed" ) ;
57
- self . clean_analysis ( ) ;
58
- status. code ( )
57
+ let result = status. code ( ) ;
58
+ if let Some ( 0 ) = result {
59
+ self . clean_analysis ( ) ;
60
+ }
61
+ result
59
62
}
60
63
61
64
// Remove any old or duplicate json files.
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ use futures::Future;
16
16
17
17
use std:: fmt;
18
18
use std:: path:: { Path , PathBuf } ;
19
- use std:: process:: Command ;
19
+ use std:: process:: { self , Command } ;
20
20
use std:: str:: FromStr ;
21
21
use std:: sync:: { Arc , Mutex , atomic:: { AtomicU32 , Ordering } } ;
22
22
use std:: thread;
@@ -74,9 +74,12 @@ impl Server {
74
74
thread:: spawn ( move || {
75
75
println ! ( "Building..." ) ;
76
76
status. start_build ( ) ;
77
- builder. build ( ) . unwrap ( ) ;
77
+ let code = builder. build ( ) . unwrap ( ) ;
78
78
status. finish_build ( ) ;
79
79
80
+ if code != 0 {
81
+ process:: exit ( 1 ) ;
82
+ }
80
83
status. start_analysis ( ) ;
81
84
file_cache. update_analysis ( ) ;
82
85
status. finish_analysis ( ) ;
You can’t perform that action at this time.
0 commit comments