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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Bilgi - Cross-platform system information crate in Rust.
//
// Bilgi can take these informations (work-in-progress):
// * OS
// * Kernel
// * Username
// * Hostname
// * Language
// * Terminal emulator
// -----
// * CPU
// * CPU core/s
// * CPU Vendor ID
//
// MIT License
//
// Copyright (c) 2021 Ferhat Geçdoğan All Rights Reserved.
// Distributed under the terms of the MIT License.
//
//

pub mod system;
pub mod helpers;
pub mod cpu;

#[cfg(test)]
mod tests {
    #[test]
    fn system_infos() {
        let infos  = crate::system::sys::init();

        let mut cpu_infos = crate::cpu::CPUInfos {
            model_name: "".to_string(),
            vendor_id : "".to_string(),
            cores     : 0
        };

        cpu_infos.init();

        println!(
            "\
            OS      : {}\n\
            Kernel  : {}\n\
            Username: {}\n\
            Hostname: {}\n\
            Language: {}\n\
            Term    : {}\n\
            --------\n\
            CPU     : {}\n\
            Cores   : {}\n\
            VendorID: {}",

            infos.os_name,
            infos.kernel,
            infos.username,
            infos.hostname,
            infos.language,

            (if !infos.emulator.1.is_empty() {
                infos.emulator.1
            } else { infos.emulator.0 }),

            cpu_infos.model_name,
            cpu_infos.cores,
            cpu_infos.vendor_id
        );
    }
}