blob: 25b5a674abaa0ab9341f49027d273030455be599 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
use chrono;
use hostname;
use term_size;
use std;
use users;
use power;
use vcs;
pub fn hostname() -> Option<String> {
hostname::get_hostname()
}
pub fn terminal_cols() -> Option<usize> {
if let Some((w, _h)) = term_size::dimensions() {
Some(w)
}
else {
None
}
}
pub fn pwd() -> Option<std::path::PathBuf> {
std::env::var("PWD").map(std::path::PathBuf::from).ok()
}
pub fn home() -> Option<std::path::PathBuf> {
std::env::var("HOME").map(std::path::PathBuf::from).ok()
}
pub fn user() -> Option<String> {
users::get_current_username()
}
pub fn is_root() -> bool {
users::get_current_uid() == 0
}
pub fn time() -> chrono::DateTime<chrono::Local> {
chrono::Local::now()
}
pub fn power_info() -> power::PowerInfo {
power::PowerInfo::new()
}
pub fn vcs_info() -> Option<Box<vcs::VcsInfo>> {
vcs::detect()
}
|