File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ pub(crate) enum DetachPathDeps {
70
70
}
71
71
72
72
impl Args {
73
- pub ( crate ) fn parse ( ) -> Result < Self > {
73
+ pub ( crate ) fn parse ( ) -> Result < Option < Self > > {
74
74
const SUBCMD : & str = "minimal-versions" ;
75
75
76
76
// rustc/cargo args must be valid Unicode
@@ -162,11 +162,11 @@ impl Args {
162
162
163
163
Short ( 'h' ) | Long ( "help" ) if subcommand. is_none ( ) => {
164
164
print ! ( "{USAGE}" ) ;
165
- std :: process :: exit ( 0 ) ;
165
+ return Ok ( None ) ;
166
166
}
167
167
Short ( 'V' ) | Long ( "version" ) if subcommand. is_none ( ) => {
168
168
println ! ( "{} {}" , env!( "CARGO_PKG_NAME" ) , env!( "CARGO_PKG_VERSION" ) ) ;
169
- std :: process :: exit ( 0 ) ;
169
+ return Ok ( None ) ;
170
170
}
171
171
172
172
// passthrough
@@ -217,15 +217,15 @@ impl Args {
217
217
cargo_args. push ( path. clone ( ) ) ;
218
218
}
219
219
220
- Ok ( Self {
220
+ Ok ( Some ( Self {
221
221
no_private,
222
222
direct,
223
223
subcommand,
224
224
manifest_path,
225
225
detach_path_deps,
226
226
cargo_args,
227
227
rest,
228
- } )
228
+ } ) )
229
229
}
230
230
}
231
231
Original file line number Diff line number Diff line change @@ -15,26 +15,28 @@ 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 ( )
30
30
|| term:: warn ( ) && env:: var_os ( "CARGO_MINIMAL_VERSIONS_DENY_WARNINGS" ) . is_some ( )
31
31
{
32
- std:: process:: exit ( 1 )
32
+ ExitCode :: FAILURE
33
+ } else {
34
+ ExitCode :: SUCCESS
33
35
}
34
36
}
35
37
36
38
fn try_main ( ) -> Result < ( ) > {
37
- let args = Args :: parse ( ) ?;
39
+ let Some ( args) = Args :: parse ( ) ? else { return Ok ( ( ) ) } ;
38
40
let ws = Workspace :: new ( args. manifest_path . as_deref ( ) , args. direct ) ?;
39
41
40
42
// Remove dev-dependencies from Cargo.toml to prevent the next `cargo update`
You can’t perform that action at this time.
0 commit comments