smokepatio/ecplorer/src/args.rs
2024-01-10 20:40:50 -05:00

53 lines
1.3 KiB
Rust

use clap::{Parser, Subcommand};
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
pub struct Args {
/// Port address of ec data
#[arg(short, long, value_parser = clap_num::maybe_hex::<u16>)]
pub data_address: u16,
/// Port address of ec cmd
#[arg(short, long, value_parser = clap_num::maybe_hex::<u16>)]
pub cmd_address: u16,
/// Use 16-bit addresses instead of 8-bit
#[arg(short, long)]
pub extended: bool,
/// Operation to perform
#[command(subcommand)]
pub op: Operation,
}
impl Args {
pub fn load() -> Self {
Self::parse()
}
}
#[derive(Subcommand, Debug)]
pub enum Operation {
/// Read whole address space, printing values
ReadAll,
/// Read a specific address
Read {
/// Address of embedded controller to read from
#[arg(value_parser = clap_num::maybe_hex::<u16>)]
address: u16,
},
/// Write a pattern to the whole address space
WritePattern {
// TODO
},
/// Write a value to a specific address
Write {
/// Address of embedded controller to write
#[arg(value_parser = clap_num::maybe_hex::<u16>)]
address: u16,
/// Value to write
#[arg(value_parser = clap_num::maybe_hex::<u8>)]
value: u8,
},
}