File tree 1 file changed +9
-7
lines changed
1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change 7
7
8
8
// spell-checker:ignore (ToDO) NPROCESSORS nprocs numstr threadstr sysconf
9
9
10
- #[ macro_use]
11
- extern crate uucore;
12
-
13
10
use clap:: { crate_version, App , Arg } ;
14
11
use std:: env;
12
+ use uucore:: display:: Quotable ;
13
+ use uucore:: error:: { UResult , USimpleError } ;
15
14
16
15
#[ cfg( target_os = "linux" ) ]
17
16
pub const _SC_NPROCESSORS_CONF: libc:: c_int = 83 ;
@@ -31,16 +30,19 @@ fn usage() -> String {
31
30
format ! ( "{0} [OPTIONS]..." , uucore:: execution_phrase( ) )
32
31
}
33
32
34
- pub fn uumain ( args : impl uucore:: Args ) -> i32 {
33
+ #[ uucore_procs:: gen_uumain]
34
+ pub fn uumain ( args : impl uucore:: Args ) -> UResult < ( ) > {
35
35
let usage = usage ( ) ;
36
36
let matches = uu_app ( ) . usage ( & usage[ ..] ) . get_matches_from ( args) ;
37
37
38
38
let mut ignore = match matches. value_of ( OPT_IGNORE ) {
39
39
Some ( numstr) => match numstr. parse ( ) {
40
40
Ok ( num) => num,
41
41
Err ( e) => {
42
- show_error ! ( "\" {}\" is not a valid number: {}" , numstr, e) ;
43
- return 1 ;
42
+ return Err ( USimpleError :: new (
43
+ 1 ,
44
+ format ! ( "{} is not a valid number: {}" , numstr. quote( ) , e) ,
45
+ ) ) ;
44
46
}
45
47
} ,
46
48
None => 0 ,
@@ -66,7 +68,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
66
68
cores -= ignore;
67
69
}
68
70
println ! ( "{}" , cores) ;
69
- 0
71
+ Ok ( ( ) )
70
72
}
71
73
72
74
pub fn uu_app ( ) -> App < ' static , ' static > {
You can’t perform that action at this time.
0 commit comments