1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
use crate::sbx_specs::SBX_FILE_UID_LEN; use crate::show_core; use crate::show_core::Param; use crate::json_printer::BracketType; use crate::cli_utils::*; use clap::*; pub fn sub_command<'a, 'b>() -> App<'a, 'b> { SubCommand::with_name("show") .about("Search for and print metadata in file") .arg(in_file_arg().help("SBX container to search for metadata")) .arg( Arg::with_name("show_all") .long("show-all") .help("Show all metadata (by default only shows the first one)"), ) .arg(only_pick_uid_arg()) .arg(force_misalign_arg()) .arg(pr_verbosity_level_arg()) .arg(guess_burst_from_byte_arg()) .arg(from_byte_arg().help(FROM_BYTE_ARG_HELP_MSG_SCAN)) .arg(to_byte_inc_arg()) .arg(to_byte_exc_arg()) .arg(guess_burst_arg()) .arg(json_arg()) } pub fn show<'a>(matches: &ArgMatches<'a>) -> i32 { let json_printer = get_json_printer!(matches); json_printer.print_open_bracket(None, BracketType::Curly); let in_file = get_in_file!(matches, json_printer); let pr_verbosity_level = get_pr_verbosity_level!(matches, json_printer); let from_pos = get_from_pos!(matches, json_printer); let to_pos = get_to_pos!(matches, json_printer); let guess_burst_from_pos = get_guess_burst_from_pos!(matches, json_printer); let mut temp_uid = [0; SBX_FILE_UID_LEN]; let uid: Option<&[u8; SBX_FILE_UID_LEN]> = get_uid!(matches, temp_uid, json_printer); let param = Param::new( matches.is_present("show_all"), matches.is_present("guess_burst"), guess_burst_from_pos, matches.is_present("force_misalign"), &json_printer, from_pos, to_pos, in_file, uid, pr_verbosity_level, ); match show_core::show_file(¶m) { Ok(s) => exit_with_msg!(ok json_printer => "{}", s), Err(e) => exit_with_msg!(op json_printer => "{}", e), } }