pub mod bridge;
pub mod capability;
pub mod config;
pub mod db;
pub mod device;
pub mod filter;
pub mod util;
fn u64_from_maybe_hex_str(s: &str) -> Result<u64, String> {
let (s, radix) = if let Some(s) = s.strip_prefix("0x") { (s, 16) } else { (s, 10) };
u64::from_str_radix(&s, radix).map_err(|e| e.to_string())
}
use argh::FromArgs;
#[derive(FromArgs, Default)]
pub struct Args {
#[argh(positional)]
pub filter: Option<filter::Filter>,
#[argh(option, default = "String::from(\"/dev/sys/platform/pt/\")")]
pub service: String,
#[argh(switch, short = 'v')]
pub verbose: bool,
#[argh(switch, short = 'q')]
pub quiet: bool,
#[argh(switch, short = 'x')]
pub print_config: bool,
#[argh(switch, short = 'n')]
pub print_numeric: bool,
#[argh(switch, short = 'N')]
pub only_print_numeric: bool,
#[argh(subcommand)]
pub command: Option<SubCommand>,
}
#[derive(Copy, Clone, FromArgs, PartialEq, Debug)]
#[argh(subcommand)]
pub enum SubCommand {
Buses(BusesCommand),
Read(ReadBarCommand),
}
#[derive(Copy, Clone, FromArgs, PartialEq, Default, Debug)]
#[argh(subcommand, name = "buses")]
pub struct BusesCommand {}
#[derive(Copy, Clone, FromArgs, PartialEq, Default, Debug)]
#[argh(subcommand, name = "read")]
pub struct ReadBarCommand {
#[argh(positional)]
pub device: filter::Filter,
#[argh(positional)]
pub bar_id: u8,
#[argh(option, short = 'o', default = "0", from_str_fn(u64_from_maybe_hex_str))]
pub offset: u64,
#[argh(option, short = 's', default = "128", from_str_fn(u64_from_maybe_hex_str))]
pub size: u64,
#[argh(switch, short = 'v')]
pub verbose: bool,
}