From c9213c1ad0b0295744388710f8b3d343a5cf0271 Mon Sep 17 00:00:00 2001 From: iximeow Date: Thu, 6 Feb 2020 00:50:52 -0800 Subject: clean up yaxdis and make for usable help --- src/main.rs | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 3a9fef4..b59ebb2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,36 +1,37 @@ -use yaxpeax_arch::{Address, Arch, Decoder, Instruction, LengthedInstruction}; +use yaxpeax_arch::{AddressBase, Arch, Decoder, Instruction, LengthedInstruction}; -use clap::{Arg, App}; +use clap::*; use num_traits::identities::Zero; use std::fmt; fn main() { - let matches = App::new("yaxpeax disassembler") - .version("0.0.1") - .author("iximeow ") - .about("disassembly tool using yaxpeax decoders") + let _ = include_str!("../Cargo.toml"); + let app = app_from_crate!() .arg(Arg::with_name("arch") .short("a") - .long("architecture") + .long("--architecture") .takes_value(true) - .help("architecture to disassemble input as")) + .possible_values(&["x86_64", "armv7", "armv8", "mips", "msp430", "pic17", "pic18", "m16c"]) + .help("architecture to disassemble input as.")) + /* .arg(Arg::with_name("file") .short("f") .long("file") .takes_value(true) .help("file of bytes to decode")) + */ .arg(Arg::with_name("verbose") .short("v") - .long("verbose") + .long("--verbose") .help("increased detail when decoding instructions")) .arg(Arg::with_name("data") - .index(1)) - .get_matches(); + .required(true) + .help("hex bytes to decode by the selected architecture. for example, try -a x86_64 33c0c3")); + + let matches = app.get_matches(); let arch_str = matches.value_of("arch").unwrap_or("x86_64"); - eprintln!("disassembling as {}", arch_str); -// let file = matches.value_of("file").unwrap(); let buf: &str = matches.value_of("data").unwrap_or(""); let verbose = matches.occurrences_of("verbose") > 0; @@ -39,9 +40,10 @@ fn main() { "armv7" => decode_input::(buf, verbose), "armv8" => decode_input::(buf, verbose), "mips" => decode_input::(buf, verbose), - "msp430" => decode_input::(buf, verbose), + "msp430" => decode_input::(buf, verbose), "pic17" => decode_input::(buf, verbose), "pic18" => decode_input::(buf, verbose), + "m16c" => decode_input::(buf, verbose), // "pic24" => decode_input::(buf), other => { println!("unsupported architecture: {}", other); -- cgit v1.1