@@ -26,9 +26,9 @@ mod platform {
26
26
pub use crate :: pslinux:: * ;
27
27
}
28
28
29
+ /// ps - report process status
29
30
#[ derive( Parser ) ]
30
- #[ command( name = "ps" ) ]
31
- #[ command( about = "Report process status" , version = "1.0" ) ]
31
+ #[ command( author, version, about, long_about) ]
32
32
struct Args {
33
33
/// List all processes
34
34
#[ arg( short = 'A' , long) ]
@@ -39,30 +39,30 @@ struct Args {
39
39
all2 : bool ,
40
40
41
41
/// List all processes associated with terminals
42
- #[ arg( short = 'a' , long ) ]
42
+ #[ arg( short = 'a' ) ]
43
43
terminal_processes : bool ,
44
44
45
45
/// Exclude session leaders
46
- #[ arg( short = 'd' , long ) ]
46
+ #[ arg( short = 'd' ) ]
47
47
exclude_session_leaders : bool ,
48
48
49
49
/// Full output format (-f)
50
- #[ arg( short = 'f' , long) ]
50
+ #[ arg( short = 'f' , long = "full" ) ]
51
51
full_format : bool ,
52
52
53
53
/// Long output format (-l)
54
- #[ arg( short = 'l' , long) ]
54
+ #[ arg( short = 'l' , long = "long" ) ]
55
55
long_format : bool ,
56
56
57
57
/// Custom output format (-o)
58
- #[ arg( short = 'o' , long , value_parser = clap:: builder:: NonEmptyStringValueParser :: new( ) ) ]
58
+ #[ arg( short = 'o' , value_parser = clap:: builder:: NonEmptyStringValueParser :: new( ) ) ]
59
59
output_format : Option < String > ,
60
60
}
61
61
62
62
// Parse the -o format option into a list of fields
63
63
fn parse_output_format < ' a > (
64
64
format : & ' a str ,
65
- posix_fields : & ' a HashMap < & ' a str , ( & ' a str , & ' a str ) > ,
65
+ posix_fields : & ' a HashMap < & ' a str , & ' a str > ,
66
66
) -> Vec < & ' a str > {
67
67
format
68
68
. split ( |c| c == ' ' || c == ',' )
@@ -78,23 +78,23 @@ fn parse_output_format<'a>(
78
78
}
79
79
80
80
// Lookup table for POSIX-compliant output fields
81
- fn posix_field_map ( ) -> HashMap < & ' static str , ( & ' static str , & ' static str ) > {
81
+ fn posix_field_map ( ) -> HashMap < & ' static str , & ' static str > {
82
82
HashMap :: from ( [
83
- ( "ruser" , ( "uid" , " RUSER") ) ,
84
- ( "user" , ( "uid" , " USER") ) ,
85
- ( "rgroup" , ( "gid" , " RGROUP") ) ,
86
- ( "group" , ( "gid" , " GROUP") ) ,
87
- ( "pid" , ( "pid" , " PID") ) ,
88
- ( "ppid" , ( "ppid" , " PPID") ) ,
89
- ( "pgid" , ( "pgid" , " PGID") ) ,
90
- ( "pcpu" , ( "pcpu" , " %CPU") ) ,
91
- ( "vsz" , ( "vsz" , " VSZ") ) ,
92
- ( "nice" , ( "nice" , " NI") ) ,
93
- ( "etime" , ( "etime" , " ELAPSED") ) ,
94
- ( "time" , ( "time" , " TIME") ) ,
95
- ( "tty" , ( "tty" , " TTY") ) ,
96
- ( "comm" , ( "comm" , " COMMAND") ) ,
97
- ( "args" , ( "args" , " COMMAND") ) ,
83
+ ( "ruser" , " RUSER") ,
84
+ ( "user" , " USER") ,
85
+ ( "rgroup" , " RGROUP") ,
86
+ ( "group" , " GROUP") ,
87
+ ( "pid" , " PID") ,
88
+ ( "ppid" , " PPID") ,
89
+ ( "pgid" , " PGID") ,
90
+ ( "pcpu" , " %CPU") ,
91
+ ( "vsz" , " VSZ") ,
92
+ ( "nice" , " NI") ,
93
+ ( "etime" , " ELAPSED") ,
94
+ ( "time" , " TIME") ,
95
+ ( "tty" , " TTY") ,
96
+ ( "comm" , " COMMAND") ,
97
+ ( "args" , " COMMAND") ,
98
98
] )
99
99
}
100
100
@@ -148,7 +148,7 @@ fn main() {
148
148
149
149
// Print the header
150
150
for field in & output_fields {
151
- let header = posix_fields. get ( * field) . unwrap_or ( & ( & field, & field ) ) . 1 ;
151
+ let header = posix_fields. get ( * field) . unwrap_or ( & field) ;
152
152
print ! ( "{:<10} " , header) ;
153
153
}
154
154
println ! ( ) ;
0 commit comments