File tree Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ pub(crate) struct Args {
30
30
}
31
31
32
32
impl Args {
33
- pub ( crate ) fn parse ( ) -> Result < Self > {
33
+ pub ( crate ) fn parse ( ) -> Result < Option < Self > > {
34
34
const SUBCMD : & str = "no-dev-deps" ;
35
35
36
36
// rustc/cargo args must be valid Unicode
@@ -99,11 +99,11 @@ impl Args {
99
99
100
100
Short ( 'h' ) | Long ( "help" ) if subcommand. is_none ( ) => {
101
101
print ! ( "{USAGE}" ) ;
102
- std :: process :: exit ( 0 ) ;
102
+ return Ok ( None ) ;
103
103
}
104
104
Short ( 'V' ) | Long ( "version" ) if subcommand. is_none ( ) => {
105
105
println ! ( "{} {}" , env!( "CARGO_PKG_NAME" ) , env!( "CARGO_PKG_VERSION" ) ) ;
106
- std :: process :: exit ( 0 ) ;
106
+ return Ok ( None ) ;
107
107
}
108
108
109
109
// passthrough
@@ -152,7 +152,7 @@ impl Args {
152
152
cargo_args. push ( path. clone ( ) ) ;
153
153
}
154
154
155
- Ok ( Self { no_private, manifest_path, cargo_args, rest } )
155
+ Ok ( Some ( Self { no_private, manifest_path, cargo_args, rest } ) )
156
156
}
157
157
}
158
158
Original file line number Diff line number Diff line change @@ -15,24 +15,26 @@ mod manifest;
15
15
mod metadata;
16
16
mod restore;
17
17
18
- use std:: env;
18
+ use std:: { env, process :: ExitCode } ;
19
19
20
20
use anyhow:: Result ;
21
21
22
22
use crate :: { cargo:: Workspace , cli:: Args } ;
23
23
24
- fn main ( ) {
24
+ fn main ( ) -> ExitCode {
25
25
term:: init_coloring ( ) ;
26
26
if let Err ( e) = try_main ( ) {
27
27
error ! ( "{e:#}" ) ;
28
28
}
29
29
if term:: error ( ) || term:: warn ( ) && env:: var_os ( "CARGO_NO_DEV_DEPS_DENY_WARNINGS" ) . is_some ( ) {
30
- std:: process:: exit ( 1 )
30
+ ExitCode :: FAILURE
31
+ } else {
32
+ ExitCode :: SUCCESS
31
33
}
32
34
}
33
35
34
36
fn try_main ( ) -> Result < ( ) > {
35
- let args = Args :: parse ( ) ?;
37
+ let Some ( args) = Args :: parse ( ) ? else { return Ok ( ( ) ) } ;
36
38
let ws = Workspace :: new ( args. manifest_path . as_deref ( ) ) ?;
37
39
38
40
let no_dev_deps = true ;
You can’t perform that action at this time.
0 commit comments