Skip to content

Commit

Permalink
Add clap feature to crosec for better fp-mode command
Browse files Browse the repository at this point in the history
  • Loading branch information
ChocolateLoverRaj committed Jun 7, 2024
1 parent c4b3560 commit 6da00c5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
13 changes: 7 additions & 6 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions crosec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ edition = "2021"

[dependencies]
bytemuck = { version = "1.16.0", features = ["derive"] }
clap = { version = "4.5.6", optional = true }
nix = { version = "0.27.1", features = ["ioctl"] }
num = "0.4.3"
num-derive = "0.4.2"
num-traits = "0.2.18"
strum = "0.26.2"
strum_macros = "0.26.4"
thiserror = "1.0.57"

[features]
clap = ["dep:clap"]
1 change: 1 addition & 0 deletions crosec/src/commands/fp_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use super::CrosEcCmd;

/// Note that with the ChromiumOS ectool, to start enrolling, as well as continue the next step in enrolling, you do `ectool --name=cros_fp fpmode enroll`. The equivalent of this is to do `ectool fp-mode EnrollImage EnrollSession`.
#[derive(EnumString, EnumIter, IntoStaticStr, Clone, Copy)]
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
#[repr(u32)]
pub enum FpMode {
Reset = 0b00000000000000000000000000000000,
Expand Down
2 changes: 1 addition & 1 deletion ectool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
crosec = { version = "0.1.0", path = "../crosec" }
crosec = { version = "0.1.0", path = "../crosec", features = ["clap"] }
color-eyre = "0.6.2"
clap = { version = "4.5.4", features = ["derive"] }
num-traits = "0.2.19"
Expand Down
4 changes: 2 additions & 2 deletions ectool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ enum Commands {
seed: String,
},
FpMode {
mode: Vec<String>,
mode: Vec<FpMode>,
},
WaitEvent {
event_type: String,
Expand Down Expand Up @@ -252,7 +252,7 @@ fn main() -> Result<()> {
let mode = if mode.len() > 0 {
let mut mode_number: u32 = 0;
for mode in mode {
mode_number |= FpMode::from_str(&mode)? as u32;
mode_number |= mode as u32;
}
mode_number
} else {
Expand Down

0 comments on commit 6da00c5

Please sign in to comment.