Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display: Add ability to skip sections #10

Merged
merged 3 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

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

13 changes: 9 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ enum CommandOpts {

#[derive(StructOpt)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it appears that structopt is being deprecated in favor of clap: https://docs.rs/structopt/latest/structopt/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see #12

struct Disp {
#[structopt(short, long)]
#[structopt(short = "r", long)]
display_raw: bool,
#[cfg(all(target_os = "linux", feature = "kvm"))]
#[structopt(long)]
skip_kvm: bool,
#[structopt(long)]
skip_msr: bool,
}

impl Command for Disp {
Expand All @@ -54,7 +59,7 @@ impl Command for Disp {
}

#[cfg(all(target_os = "linux", feature = "kvm"))]
{
if !self.skip_kvm {
use cpuinfo::kvm::KvmInfo;
use kvm_ioctls::Kvm;
println!("KVM-CPUID:");
Expand All @@ -72,7 +77,7 @@ impl Command for Disp {
}
}

if MSRDesc::is_availible() {
if MSRDesc::is_available() && !self.skip_msr {
println!("MSRS:");
for msr in &config.msrs {
match msr.into_value() {
Expand Down Expand Up @@ -114,7 +119,7 @@ fn collect_facts(
CpuidType::KvmInfo(_) => true,
};

if MSRDesc::is_availible() && !use_kvm {
if MSRDesc::is_available() && !use_kvm {
for msr in &config.msrs {
if let Ok(value) = MSRValue::try_from(msr) {
let mut facts = value.collect_facts();
Expand Down
4 changes: 2 additions & 2 deletions src/msr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl MSRDesc {
Ok(u64::from_le_bytes(msr_bytes))
}
#[cfg(all(target_os = "linux", feature = "use_msr"))]
pub fn is_availible() -> bool {
pub fn is_available() -> bool {
true
}

Expand All @@ -78,7 +78,7 @@ impl MSRDesc {
Err(Error::NotAvailible)
}
#[cfg(any(not(target_os = "linux"), not(feature = "use_msr")))]
pub fn is_availible() -> bool {
pub fn is_available() -> bool {
false
}

Expand Down