File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ use std::collections::HashMap;
5
5
use std:: env;
6
6
use std:: fs:: { self , File } ;
7
7
use std:: io:: { self , Error , Read , Write } ;
8
+ use sys_info:: { cpu_num, cpu_speed, os_release} ;
8
9
use std:: path:: Path ;
9
10
use std:: thread:: { self , sleep} ;
10
11
use std:: time:: { Duration , SystemTime , UNIX_EPOCH } ;
@@ -1097,6 +1098,17 @@ impl Executor {
1097
1098
self . stack . push ( Type :: Bool ( path. is_dir ( ) ) ) ;
1098
1099
}
1099
1100
1101
+ // Get system information
1102
+ "sys-info" => {
1103
+ let types = self . pop_stack ( ) . get_string ( ) ;
1104
+ self . stack . push ( match types. as_str ( ) {
1105
+ "os-release" => Type :: String ( os_release ( ) . unwrap_or ( "" . to_string ( ) ) ) ,
1106
+ "cpu-num" => Type :: Number ( cpu_num ( ) . unwrap_or ( 0 ) as f64 ) ,
1107
+ "cpu-speed" => Type :: Number ( cpu_speed ( ) . unwrap_or ( 0 ) as f64 ) ,
1108
+ _ => Type :: Error ( "sys-info" . to_string ( ) )
1109
+ } )
1110
+ }
1111
+
1100
1112
// If it is not recognized as a command, use it as a string.
1101
1113
_ => self . stack . push ( Type :: String ( command) ) ,
1102
1114
}
You can’t perform that action at this time.
0 commit comments