Skip to content

Commit

Permalink
Merge pull request #4897 from sylvestre/platform-info
Browse files Browse the repository at this point in the history
update to platform-info 2.0.1
  • Loading branch information
cakebaker authored May 31, 2023
2 parents 0802630 + f830b6e commit 8940018
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 4 additions & 3 deletions src/uu/arch/src/arch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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(())
}

Expand Down
19 changes: 9 additions & 10 deletions src/uu/uname/src/uname.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand All @@ -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);
Expand 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(' ');
}

Expand Down

0 comments on commit 8940018

Please sign in to comment.