mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 20:17:45 +00:00
Merge pull request #4897 from sylvestre/platform-info
update to platform-info 2.0.1
This commit is contained in:
commit
8940018833
4 changed files with 16 additions and 16 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -1712,9 +1712,9 @@ checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160"
|
|||
|
||||
[[package]]
|
||||
name = "platform-info"
|
||||
version = "1.0.2"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e7c23cfae725ae06d9e43010153fa77bdfa8c827bf08fe4beeb2a3514e6be12"
|
||||
checksum = "827dc4f7a81331d48c8abf11b5ac18673b390d33e9632327e286d940289aefab"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"winapi",
|
||||
|
|
|
@ -304,7 +304,7 @@ onig = { version = "~6.4", default-features = false }
|
|||
ouroboros = "0.15.6"
|
||||
phf = "0.11.1"
|
||||
phf_codegen = "0.11.1"
|
||||
platform-info = "1.0.2"
|
||||
platform-info = "2.0.1"
|
||||
quick-error = "2.0.1"
|
||||
rand = { version = "0.8", features = ["small_rng"] }
|
||||
rand_core = "0.6"
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
use platform_info::*;
|
||||
|
||||
use clap::{crate_version, Command};
|
||||
use uucore::error::{FromIo, UResult};
|
||||
use uucore::error::{UResult, USimpleError};
|
||||
use uucore::{help_about, help_section};
|
||||
|
||||
static ABOUT: &str = help_about!("arch.md");
|
||||
|
@ -19,8 +19,9 @@ static SUMMARY: &str = help_section!("after help", "arch.md");
|
|||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
uu_app().try_get_matches_from(args)?;
|
||||
|
||||
let uts = PlatformInfo::new().map_err_context(|| "cannot get system name".to_string())?;
|
||||
println!("{}", uts.machine().trim());
|
||||
let uts = PlatformInfo::new().map_err(|_e| USimpleError::new(1, "cannot get system name"))?;
|
||||
|
||||
println!("{}", uts.machine().to_string_lossy().trim());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
use clap::{crate_version, Arg, ArgAction, Command};
|
||||
use platform_info::*;
|
||||
use uucore::{
|
||||
error::{FromIo, UResult},
|
||||
error::{UResult, USimpleError},
|
||||
format_usage, help_about, help_usage,
|
||||
};
|
||||
|
||||
|
@ -36,8 +36,8 @@ pub mod options {
|
|||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let matches = uu_app().try_get_matches_from(args)?;
|
||||
|
||||
let uname =
|
||||
PlatformInfo::new().map_err_context(|| "failed to create PlatformInfo".to_string())?;
|
||||
let uname = PlatformInfo::new().map_err(|_e| USimpleError::new(1, "cannot get system name"))?;
|
||||
|
||||
let mut output = String::new();
|
||||
|
||||
let all = matches.get_flag(options::ALL);
|
||||
|
@ -61,33 +61,32 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
|| hardware_platform);
|
||||
|
||||
if kernel_name || all || none {
|
||||
output.push_str(&uname.sysname());
|
||||
output.push_str(&uname.sysname().to_string_lossy());
|
||||
output.push(' ');
|
||||
}
|
||||
|
||||
if nodename || all {
|
||||
// maint: [2023-01-14; rivy] remove `.trim_end_matches('\0')` when platform-info nodename-NUL bug is fixed (see GH:uutils/platform-info/issues/32)
|
||||
output.push_str(uname.nodename().trim_end_matches('\0'));
|
||||
output.push_str(&uname.nodename().to_string_lossy());
|
||||
output.push(' ');
|
||||
}
|
||||
|
||||
if kernel_release || all {
|
||||
output.push_str(&uname.release());
|
||||
output.push_str(&uname.release().to_string_lossy());
|
||||
output.push(' ');
|
||||
}
|
||||
|
||||
if kernel_version || all {
|
||||
output.push_str(&uname.version());
|
||||
output.push_str(&uname.version().to_string_lossy());
|
||||
output.push(' ');
|
||||
}
|
||||
|
||||
if machine || all {
|
||||
output.push_str(&uname.machine());
|
||||
output.push_str(&uname.machine().to_string_lossy());
|
||||
output.push(' ');
|
||||
}
|
||||
|
||||
if os || all {
|
||||
output.push_str(&uname.osname());
|
||||
output.push_str(&uname.osname().to_string_lossy());
|
||||
output.push(' ');
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue