66use std:: cell:: RefCell ;
77
88use uu_pgrep:: process:: { ProcessInformation , Teletype } ;
9+ use uucore:: entries:: { gid2grp, uid2usr} ;
910
1011pub ( crate ) fn collect_pickers (
1112 code_order : & [ String ] ,
@@ -15,6 +16,17 @@ pub(crate) fn collect_pickers(
1516 for code in code_order {
1617 match code. as_str ( ) {
1718 "pid" | "tgid" => pickers. push ( helper ( pid) ) ,
19+ "ppid" => pickers. push ( helper ( ppid) ) ,
20+ "uid" => pickers. push ( helper ( uid) ) ,
21+ "euid" => pickers. push ( helper ( euid) ) ,
22+ "user" => pickers. push ( helper ( user) ) ,
23+ "euser" => pickers. push ( helper ( euser) ) ,
24+ "pgid" => pickers. push ( helper ( pgid) ) ,
25+ "sid" => pickers. push ( helper ( sid) ) ,
26+ "gid" => pickers. push ( helper ( gid) ) ,
27+ "egid" => pickers. push ( helper ( egid) ) ,
28+ "group" => pickers. push ( helper ( group) ) ,
29+ "egroup" => pickers. push ( helper ( egroup) ) ,
1830 "tname" | "tt" | "tty" => pickers. push ( helper ( tty) ) ,
1931 "time" | "cputime" => pickers. push ( helper ( time) ) ,
2032 "ucmd" => pickers. push ( helper ( ucmd) ) ,
@@ -34,7 +46,55 @@ fn helper(
3446}
3547
3648fn pid ( proc_info : RefCell < ProcessInformation > ) -> String {
37- format ! ( "{}" , proc_info. borrow( ) . pid)
49+ proc_info. borrow ( ) . pid . to_string ( )
50+ }
51+
52+ fn ppid ( proc_info : RefCell < ProcessInformation > ) -> String {
53+ proc_info. borrow_mut ( ) . ppid ( ) . unwrap ( ) . to_string ( )
54+ }
55+
56+ fn uid ( proc_info : RefCell < ProcessInformation > ) -> String {
57+ proc_info. borrow_mut ( ) . uid ( ) . unwrap ( ) . to_string ( )
58+ }
59+
60+ fn euid ( proc_info : RefCell < ProcessInformation > ) -> String {
61+ proc_info. borrow_mut ( ) . euid ( ) . unwrap ( ) . to_string ( )
62+ }
63+
64+ fn user ( proc_info : RefCell < ProcessInformation > ) -> String {
65+ let uid = proc_info. borrow_mut ( ) . uid ( ) . unwrap ( ) ;
66+ uid2usr ( uid) . ok ( ) . unwrap_or_else ( || uid. to_string ( ) )
67+ }
68+
69+ fn euser ( proc_info : RefCell < ProcessInformation > ) -> String {
70+ let euid = proc_info. borrow_mut ( ) . euid ( ) . unwrap ( ) ;
71+ uid2usr ( euid) . ok ( ) . unwrap_or_else ( || euid. to_string ( ) )
72+ }
73+
74+ fn gid ( proc_info : RefCell < ProcessInformation > ) -> String {
75+ proc_info. borrow_mut ( ) . gid ( ) . unwrap ( ) . to_string ( )
76+ }
77+
78+ fn egid ( proc_info : RefCell < ProcessInformation > ) -> String {
79+ proc_info. borrow_mut ( ) . egid ( ) . unwrap ( ) . to_string ( )
80+ }
81+
82+ fn group ( proc_info : RefCell < ProcessInformation > ) -> String {
83+ let gid = proc_info. borrow_mut ( ) . gid ( ) . unwrap ( ) ;
84+ gid2grp ( gid) . ok ( ) . unwrap_or_else ( || gid. to_string ( ) )
85+ }
86+
87+ fn egroup ( proc_info : RefCell < ProcessInformation > ) -> String {
88+ let egid = proc_info. borrow_mut ( ) . egid ( ) . unwrap ( ) ;
89+ gid2grp ( egid) . ok ( ) . unwrap_or_else ( || egid. to_string ( ) )
90+ }
91+
92+ fn pgid ( proc_info : RefCell < ProcessInformation > ) -> String {
93+ proc_info. borrow_mut ( ) . pgid ( ) . unwrap ( ) . to_string ( )
94+ }
95+
96+ fn sid ( proc_info : RefCell < ProcessInformation > ) -> String {
97+ proc_info. borrow_mut ( ) . sid ( ) . unwrap ( ) . to_string ( )
3898}
3999
40100fn tty ( proc_info : RefCell < ProcessInformation > ) -> String {
0 commit comments