1use check_core;
2use check_core::Param;
3
4use clap::*;
5use cli_utils::*;
6
7use json_printer::BracketType;
8
9pub fn sub_command<'a, 'b>() -> App<'a, 'b> {
10 SubCommand::with_name("check")
11 .about("Check integrity of SBX blocks in container
12
13===== IMPORTANT =====
14Please note that this is the last version of this software to be released under the name rsbx,
15future releases will be published under the name blkar. See project repo for details.
16=====================")
17 .arg(in_file_arg()
18 .help("SBX container to check"))
19 .arg(no_meta_arg())
20 .arg(pr_verbosity_level_arg())
21 .arg(Arg::with_name("report_blank")
22 .long("report-blank")
23 .help("Completely blank blocks are ignored by default.
24Specify this if you want rsbx to report blank blocks as well."))
25 .arg(verbose_arg()
26 .help("Show reference block info, show individual check results"))
27 .arg(json_arg())
28}
29
30pub fn check<'a>(matches : &ArgMatches<'a>) -> i32 {
31 let json_printer = get_json_printer!(matches);
32
33 json_printer.print_open_bracket(None, BracketType::Curly);
34
35 let pr_verbosity_level = get_pr_verbosity_level!(matches, json_printer);
36
37 let in_file = get_in_file!(matches, json_printer);
38 let param = Param::new(get_ref_block_choice!(matches),
39 matches.is_present("report_blank"),
40 &json_printer,
41 in_file,
42 matches.is_present("verbose"),
43 pr_verbosity_level);
44 match check_core::check_file(¶m) {
45 Ok(Some(s)) => exit_with_msg!(ok json_printer => "{}", s),
46 Ok(None) => exit_with_msg!(ok json_printer => ""),
47 Err(e) => exit_with_msg!(op json_printer => "{}", e),
48 }
49}