Skip to content

Commit a48b426

Browse files
committed
update clap
1 parent f89fdd7 commit a48b426

File tree

26 files changed

+3101
-3316
lines changed

26 files changed

+3101
-3316
lines changed

.github/workflows/ci-version.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
os:
4242
- ubuntu-latest
4343
toolchain:
44-
- 1.69
44+
- "1.70"
4545
target:
4646
- x86_64-unknown-linux-gnu
4747
- x86_64-unknown-linux-musl

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
os:
5858
- ubuntu-latest
5959
toolchain:
60-
- 1.69
60+
- "1.70"
6161
target:
6262
- x86_64-unknown-linux-gnu
6363
- x86_64-unknown-linux-musl

Cargo.toml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[package]
22
name = "mprober"
3-
version = "0.11.0-beta.14"
3+
version = "0.11.0-beta.15"
44
authors = ["Magic Len <len@magiclen.org>"]
55
edition = "2021"
6-
rust-version = "1.69"
6+
rust-version = "1.70"
77
repository = "https://github.com/magiclen/m-prober"
88
homepage = "https://magiclen.org/m-prober"
99
keywords = ["probe", "mprober", "m-prober", "linux", "monitor"]
@@ -18,15 +18,18 @@ codegen-units = 1
1818
strip = true
1919

2020
[dependencies]
21-
mprober-lib = "0.1"
22-
23-
clap = "3.2.23"
21+
clap = { version = "4", features = ["derive"] }
2422
concat-with = "0.2"
25-
terminal_size = "0.2"
23+
terminal_size = "0.3"
24+
25+
anyhow = "1"
26+
27+
mprober-lib = "0.1"
2628

27-
byte-unit = "4"
2829
termcolor = "1"
2930
getch = "0.3"
31+
32+
byte-unit = "4"
3033
once_cell = "1"
3134

3235
rand = "0.8"

README.md

Lines changed: 77 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -9,84 +9,83 @@ This program aims to collect Linux system information including hostname, kernel
99

1010
```
1111
EXAMPLES:
12-
mprober hostname # Show the hostname
13-
mprober kernel # Show the kernel version
14-
mprober uptime # Show the uptime
15-
mprober uptime -m # Show the uptime and refresh every second
16-
mprober uptime -p # Show the uptime without colors
17-
mprober uptime -l # Show the uptime with darker colors (fitting in with light themes)
18-
mprober uptime -s # Show the uptime in seconds
19-
mprober time # Show the RTC (UTC) date and time
20-
mprober time -m # Show the RTC (UTC) date and time and refresh every second
21-
mprober time -p # Show the RTC (UTC) date and time without colors
22-
mprober time -l # Show the RTC (UTC) date and time with darker colors (fitting in with light themes)
23-
mprober cpu # Show load average and current CPU stats on average
24-
mprober cpu -m 1000 # Show load average and CPU stats on average and refresh every 1000 milliseconds
25-
mprober cpu -p # Show load average and current CPU stats on average without colors
26-
mprober cpu -l # Show load average and current CPU stats on average with darker colors (fitting in with light themes)
27-
mprober cpu -s # Show load average and current stats of CPU cores separately
28-
mprober cpu -i # Only show CPU information
29-
mprober memory # Show current memory stats
30-
mprober memory -m 1000 # Show memory stats and refresh every 1000 milliseconds
31-
mprober memory -p # Show current memory stats without colors
32-
mprober memory -l # Show current memory stats with darker colors (fitting in with light themes)
33-
mprober memory -u kb # Show current memory stats in KB
34-
mprober network # Show current network stats
35-
mprober network -m 1000 # Show network stats and refresh every 1000 milliseconds
36-
mprober network -p # Show current network stats without colors
37-
mprober network -l # Show current network stats with darker colors (fitting in with light themes)
38-
mprober network -u kb # Show current network stats in KB
39-
mprober volume # Show current volume stats
40-
mprober volume -m 1000 # Show current volume stats and refresh every 1000 milliseconds
41-
mprober volume -p # Show current volume stats without colors
42-
mprober volume -l # Show current volume stats without colors
43-
mprober volume -u kb # Show current volume stats in KB
44-
mprober volume -i # Only show volume information without I/O rates
45-
mprober volume --mounts # Show current volume stats including mount points
46-
mprober process # Show a snapshot of the current processes
47-
mprober process -m 1000 # Show a snapshot of the current processes and refresh every 1000 milliseconds
48-
mprober process -p # Show a snapshot of the current processes without colors
49-
mprober process -l # Show a snapshot of the current processes with darker colors (fitting in with light themes)
50-
mprober process -i # Show a snapshot of the current processes but not including CPU usage
51-
mprober process -u kb # Show a snapshot of the current processes. Information about memory size is in KB
52-
mprober process --truncate 10 # Show a snapshot of the current processes with a specific truncation length to truncate user, group, program's names
53-
mprober process --top 10 # Show a snapshot of current top-10 (ordered by CPU and memory usage) processes
54-
mprober process -t # Show a snapshot of the current processes with the start time of each process
55-
mprober process --pid-filter 3456 # Show a snapshot of the current processes which are related to a specific PID
56-
mprober process --user-filter user1 # Show a snapshot of the current processes which are related to a specific user
57-
mprober process --group-filter gp1 # Show a snapshot of the current processes which are related to a specific group
58-
mprober process --tty-filter tty # Show a snapshot of the current processes which are related to specific tty names matched by a regex
59-
mprober process --program-filter ab # Show a snapshot of the current processes which are related to specific program names or commands matched by a regex
60-
mprober web # Start a HTTP service on port 8000 to monitor this computer. The default time interval is 3 seconds
61-
mprober web -m 2 # Start a HTTP service on port 8000 to monitor this computer. The time interval is set to 2 seconds
62-
mprober web -p 7777 # Start a HTTP service on port 7777 to monitor this computer
63-
mprober web --addr 127.0.0.1 # Start a HTTP service on 127.0.0.1:8000 to monitor this computer
64-
mprober web -a auth_key # Start a HTTP service on port 8000 to monitor this computer. APIs need to be invoked with an auth key
65-
mprober web --only-api # Start a HTTP service on port 8000 to serve only HTTP APIs
66-
mprober benchmark # Run benchmarks
67-
mprober benchmark --disable-cpu # Run benchmarks except for benchmarking CPU
68-
mprober benchmark --enable-memory # Benchmark the memory
69-
70-
USAGE:
71-
mprober [SUBCOMMAND]
72-
73-
OPTIONS:
74-
-h, --help Print help information
75-
-V, --version Print version information
76-
77-
SUBCOMMANDS:
78-
hostname Show the hostname
79-
kernel Show the kernel version
80-
uptime Show the uptime
81-
time Show the RTC (UTC) date and time
82-
cpu Show CPU stats
83-
memory Show memory stats
84-
network Show network stats
85-
volume Show volume stats
86-
process Show process stats
87-
web Start a HTTP service to monitor this computer
88-
benchmark Run benchmarks to measure the performance of this environment
89-
help Print this message or the help of the given subcommand(s)
12+
mprober hostname # Show the hostname
13+
mprober kernel # Show the kernel version
14+
mprober uptime # Show the uptime
15+
mprober uptime -m # Show the uptime and refresh every second
16+
mprober uptime -p # Show the uptime without colors
17+
mprober uptime -l # Show the uptime with darker colors (fitting in with light themes)
18+
mprober uptime -s # Show the uptime in seconds
19+
mprober time # Show the RTC (UTC) date and time
20+
mprober time -m # Show the RTC (UTC) date and time and refresh every second
21+
mprober time -p # Show the RTC (UTC) date and time without colors
22+
mprober time -l # Show the RTC (UTC) date and time with darker colors (fitting in with light themes)
23+
mprober cpu # Show load average and current CPU stats on average
24+
mprober cpu -m 1000 # Show load average and CPU stats on average and refresh every 1000 milliseconds
25+
mprober cpu -p # Show load average and current CPU stats on average without colors
26+
mprober cpu -l # Show load average and current CPU stats on average with darker colors (fitting in with light themes)
27+
mprober cpu -s # Show load average and current stats of CPU cores separately
28+
mprober cpu -i # Only show CPU information
29+
mprober memory # Show current memory stats
30+
mprober memory -m 1000 # Show memory stats and refresh every 1000 milliseconds
31+
mprober memory -p # Show current memory stats without colors
32+
mprober memory -l # Show current memory stats with darker colors (fitting in with light themes)
33+
mprober memory -u kb # Show current memory stats in KB
34+
mprober network # Show current network stats
35+
mprober network -m 1000 # Show network stats and refresh every 1000 milliseconds
36+
mprober network -p # Show current network stats without colors
37+
mprober network -l # Show current network stats with darker colors (fitting in with light themes)
38+
mprober network -u kb # Show current network stats in KB
39+
mprober volume # Show current volume stats
40+
mprober volume -m 1000 # Show current volume stats and refresh every 1000 milliseconds
41+
mprober volume -p # Show current volume stats without colors
42+
mprober volume -l # Show current volume stats without colors
43+
mprober volume -u kb # Show current volume stats in KB
44+
mprober volume -i # Only show volume information without I/O rates
45+
mprober volume --mounts # Show current volume stats including mount points
46+
mprober process # Show a snapshot of the current processes
47+
mprober process -m 1000 # Show a snapshot of the current processes and refresh every 1000 milliseconds
48+
mprober process -p # Show a snapshot of the current processes without colors
49+
mprober process -l # Show a snapshot of the current processes with darker colors (fitting in with light themes)
50+
mprober process -i # Show a snapshot of the current processes but not including CPU usage
51+
mprober process -u kb # Show a snapshot of the current processes. Information about memory size is in KB
52+
mprober process --truncate 10 # Show a snapshot of the current processes with a specific truncation length to truncate user, group, program's names
53+
mprober process --top 10 # Show a snapshot of current top-10 (ordered by CPU and memory usage) processes
54+
mprober process -t # Show a snapshot of the current processes with the start time of each process
55+
mprober process --pid-filter 3456 # Show a snapshot of the current processes which are related to a specific PID
56+
mprober process --user-filter user1 # Show a snapshot of the current processes which are related to a specific user
57+
mprober process --group-filter gp1 # Show a snapshot of the current processes which are related to a specific group
58+
mprober process --tty-filter tty # Show a snapshot of the current processes which are related to specific tty names matched by a regex
59+
mprober process --program-filter ab # Show a snapshot of the current processes which are related to specific program names or commands matched by a regex
60+
mprober web # Start a HTTP service on port 8000 to monitor this computer. The default time interval is 3 seconds
61+
mprober web -m 2 # Start a HTTP service on port 8000 to monitor this computer. The time interval is set to 2 seconds
62+
mprober web -p 7777 # Start a HTTP service on port 7777 to monitor this computer
63+
mprober web --addr 127.0.0.1 # Start a HTTP service on 127.0.0.1:8000 to monitor this computer
64+
mprober web -a auth_key # Start a HTTP service on port 8000 to monitor this computer. APIs need to be invoked with an auth key
65+
mprober web --only-api # Start a HTTP service on port 8000 to serve only HTTP APIs
66+
mprober benchmark # Run benchmarks
67+
mprober benchmark --disable-cpu # Run benchmarks except for benchmarking CPU
68+
mprober benchmark --enable-memory # Benchmark the memory
69+
70+
Usage: mprober <COMMAND>
71+
72+
Commands:
73+
hostname Show the hostname
74+
kernel Show the kernel version
75+
uptime Show the uptime
76+
time Show the RTC (UTC) date and time
77+
cpu Show CPU stats
78+
memory Show memory stats
79+
network Show network stats
80+
volume Show volume stats
81+
process Show process stats
82+
web Start a HTTP service to monitor this computer
83+
benchmark Run benchmarks to measure the performance of this environment
84+
help Print this message or the help of the given subcommand(s)
85+
86+
Options:
87+
-h, --help Print help
88+
-V, --version Print version
9089
```
9190

9291
## Requirements

src/benchmark/mod.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use rand::{self, Rng};
1818

1919
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
2020
pub enum BenchmarkLog {
21+
#[allow(unused)]
2122
None,
2223
Normal,
2324
Verbose,
@@ -46,6 +47,7 @@ impl BenchmarkLog {
4647
#[derive(Debug)]
4748
pub enum BenchmarkError {
4849
ScannerError(ScannerError),
50+
#[allow(clippy::enum_variant_names)]
4951
BenchmarkError(benchmarking::BenchmarkError),
5052
IOError(io::Error),
5153
NoNeedBenchmark,
@@ -195,7 +197,7 @@ pub fn run_benchmark(config: &BenchmarkConfig) -> Result<BenchmarkResult, Benchm
195197
cpu_multi_thread = Some(speed);
196198

197199
if config.print_out.has_stdout() {
198-
println!("CPU (multi-thread) : {:.2} iterations/s", speed);
200+
println!("CPU (multi-thread) : {speed:.2} iterations/s");
199201

200202
if config.print_out.has_stderr() {
201203
eprintln!();
@@ -241,7 +243,7 @@ pub fn run_benchmark(config: &BenchmarkConfig) -> Result<BenchmarkResult, Benchm
241243
cpu_single_thread = Some(speed);
242244

243245
if config.print_out.has_stdout() {
244-
println!("CPU (single thread): {:.2} iterations/s", speed);
246+
println!("CPU (single thread): {speed:.2} iterations/s");
245247
}
246248
}
247249
}
@@ -298,7 +300,7 @@ pub fn run_benchmark(config: &BenchmarkConfig) -> Result<BenchmarkResult, Benchm
298300
.get_appropriate_unit(true)
299301
.to_string();
300302

301-
println!("Memory : {}/s", memory_result);
303+
println!("Memory : {memory_result}/s");
302304
}
303305
}
304306
}
@@ -538,7 +540,7 @@ pub fn run_benchmark(config: &BenchmarkConfig) -> Result<BenchmarkResult, Benchm
538540
s.push(' ');
539541
}
540542

541-
println!("{}: Read {}/s, Write {}/s", s, read_result_string, write_result_string);
543+
println!("{s}: Read {read_result_string}/s, Write {write_result_string}/s");
542544

543545
unsafe {
544546
s.as_mut_vec()

0 commit comments

Comments
 (0)