1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 12:07:46 +00:00

Merge pull request #1624 from sylvestre/uptime-refresh

refactor(uptime): some minor improvements
This commit is contained in:
Sylvestre Ledru 2020-11-20 10:02:13 +01:00 committed by GitHub
commit 6fc4129daf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 5 deletions

1
Cargo.lock generated
View file

@ -2258,7 +2258,6 @@ version = "0.0.1"
dependencies = [ dependencies = [
"chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
"clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.4", "uucore 0.0.4",
"uucore_procs 0.0.4", "uucore_procs 0.0.4",

View file

@ -15,10 +15,9 @@ edition = "2018"
path = "src/uptime.rs" path = "src/uptime.rs"
[dependencies] [dependencies]
getopts = "0.2.18"
time = "0.1.40" time = "0.1.40"
chrono = "0.4" chrono = "0.4"
clap = "2.32" clap = "2.33"
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features=["libc", "utmpx"] } uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features=["libc", "utmpx"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" } uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }

View file

@ -27,7 +27,7 @@ static VERSION: &str = env!("CARGO_PKG_VERSION");
static ABOUT: &str = "Display the current time, the length of time the system has been up,\n\ static ABOUT: &str = "Display the current time, the length of time the system has been up,\n\
the number of users on the system, and the average number of jobs\n\ the number of users on the system, and the average number of jobs\n\
in the run queue over the last 1, 5 and 15 minutes."; in the run queue over the last 1, 5 and 15 minutes.";
static OPT_SINCE: &str = "SINCE"; static OPT_SINCE: &str = "since";
#[cfg(unix)] #[cfg(unix)]
use uucore::libc::getloadavg; use uucore::libc::getloadavg;
@ -50,7 +50,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
.arg( .arg(
Arg::with_name(OPT_SINCE) Arg::with_name(OPT_SINCE)
.short("s") .short("s")
.long("since") .long(OPT_SINCE)
.help("system up since"), .help("system up since"),
) )
.get_matches_from(args); .get_matches_from(args);

View file

@ -28,3 +28,9 @@ fn test_uptime_since() {
let re = Regex::new(r"\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}").unwrap(); let re = Regex::new(r"\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}").unwrap();
assert!(re.is_match(&result.stdout.trim())); assert!(re.is_match(&result.stdout.trim()));
} }
#[test]
fn test_failed() {
let (_at, mut ucmd) = at_and_ucmd!();
ucmd.arg("willfail").fails();
}