Skip to content

Commit aacaf3a

Browse files
committed
Add efi_guids::EFI_WELL_KNOWN_GUIDS map
Add efi_guids::EFI_WELL_KNOWN_GUIDS map and logic to print list of guids.
1 parent fe20dd3 commit aacaf3a

File tree

11 files changed

+565
-109
lines changed

11 files changed

+565
-109
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ path = "src/bin/efivar.rs"
1818

1919
[dependencies]
2020
clap = { version = "4.1.13", default-features = false, features = ["std", "cargo", "help", "wrap_help", "usage"] }
21+
lazy_static = "1.4.0"

src/bin/efivar.rs

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,9 @@
1-
extern crate efivar;
2-
31
use clap;
4-
use efivar::{efivar_display, efi_variable_attributes};
5-
use std::collections::HashSet;
6-
use std::convert::TryInto;
2+
use efivar::{efi_guids, efi_variable_attributes, efivar_display};
73
use std::process::ExitCode;
84

9-
#[derive(Eq, Hash, PartialEq)]
10-
enum ActionType {
11-
Append,
12-
Export,
13-
Import,
14-
List,
15-
ListGuids,
16-
Print,
17-
Write
18-
}
19-
20-
#[derive(Eq, Hash, PartialEq)]
21-
struct EfivarAction(ActionType);
22-
23-
fn main() -> ExitCode {
24-
let parser = clap::command!()
5+
fn create_parser() -> clap::Command {
6+
return clap::command!()
257
.args_override_self(true)
268
.disable_help_flag(true)
279
.disable_version_flag(true)
@@ -37,7 +19,7 @@ fn main() -> ExitCode {
3719
.short('l')
3820
.long("list")
3921
.help("list current variables")
40-
.action(clap::ArgAction::Set)
22+
.action(clap::ArgAction::SetTrue)
4123
)
4224
.arg(clap::Arg::new("print")
4325
.short('p')
@@ -114,7 +96,21 @@ fn main() -> ExitCode {
11496
.long("usage")
11597
.help("ignored for compatibility")
11698
.action(clap::ArgAction::Help)
117-
)
118-
.get_matches();
99+
);
100+
}
101+
102+
fn main() -> ExitCode {
103+
let matches = create_parser().get_matches();
104+
if matches.get_flag("list-guids") {
105+
for g in efi_guids::EFI_WELL_KNOWN_GUIDS
106+
.sort_by_guid()
107+
.split_last()
108+
.unwrap()
109+
.1
110+
.iter()
111+
{
112+
print!("{}", g);
113+
}
114+
}
119115
return std::process::ExitCode::from(0);
120116
}

0 commit comments

Comments
 (0)