Skip to content

Commit

Permalink
clap::ValueEnum for EcMkbpEventType
Browse files Browse the repository at this point in the history
  • Loading branch information
ChocolateLoverRaj committed Jun 8, 2024
1 parent 80f4101 commit 16e89ed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions crosec/src/wait_event/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::{

use bytemuck::{from_bytes, Pod, Zeroable};
use num_derive::FromPrimitive;
use strum_macros::{EnumString, IntoStaticStr};

use crate::wait_event::fingerprint::EcMkbpEventFingerprint;

Expand Down Expand Up @@ -33,7 +32,8 @@ pub enum EcMkbpEvent {
CecEvent(u32),
}

#[derive(Debug, IntoStaticStr, EnumString, FromPrimitive, Clone, Copy)]
#[derive(Debug, FromPrimitive, Clone, Copy)]
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
#[repr(u8)]
pub enum EcMkbpEventType {
KeyMatrix,
Expand Down
6 changes: 2 additions & 4 deletions ectool/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::fs::File;
use std::str::FromStr;

use charge_control_subcommand::{charge_control_subcommand, ChargeControlSubcommand};
use clap::{Parser, Subcommand, ValueEnum};
Expand Down Expand Up @@ -105,7 +104,7 @@ enum Commands {
mode: Vec<FpMode>,
},
WaitEvent {
event_type: String,
event_type: EcMkbpEventType,
/// Timeout in milliseconds
timeout: Option<i32>,
#[arg(short, long)]
Expand Down Expand Up @@ -270,8 +269,7 @@ fn main() -> Result<()> {
timeout,
} => {
let mut file = File::open(device.unwrap_or_default().get_path())?;
let result =
wait_event(&mut file, EcMkbpEventType::from_str(&event_type)?, timeout).unwrap();
let result = wait_event(&mut file, event_type, timeout).unwrap();
println!("{result:#?}");
}
Commands::FpDownload { command } => fp_download_subcommand(command)?,
Expand Down

0 comments on commit 16e89ed

Please sign in to comment.