use clap::{Arg, ArgMatches};
use crate::utility::ERROR;
use crate::version::*;
pub fn get_cmdline_param() -> ArgMatches {
let match1 = clap::Command::new(TOOL_NAME)
.version(TOOL_VERSION)
.author(AUTHOR)
.about("D88 Disk Image Dump.")
.arg(
Arg::new("*.D88")
.help("D88 Disk Image")
.required(true)
.index(1),
)
.arg(
Arg::new("TRACK,SIDE,SECTOR")
.help("Sector position\n <TRACK> 0,1,2, ...\n <SIDE> 0:front or 1:back\n <SECTOR> 1,2,3, ...")
.takes_value(true)
.long("position")
.short('p'),
)
.arg(
Arg::new("no-info")
.help("No information")
.short('n')
.long("no-info"),
)
.arg(
Arg::new("no-color")
.help("No color")
.long("no-color"),
)
.arg(
Arg::new("summary")
.help("Summary only")
.long("summary"),
)
.arg(
Arg::new("verbose")
.help("Verbose report")
.short('v')
.long("verbose"),
)
.arg(
Arg::new("Sort by Disk Sector Order")
.help("Sort by disk sector order")
.short('s')
.long("sort"),
)
.get_matches();
match1
}
pub fn get_str_to_u8(
s: &str, err_mes: &str, ) -> Result<u8, ()> {
if let Ok(val) = s.parse() {
Ok(val)
} else {
let mes = format!("{}? {}", s, err_mes);
ERROR(mes.as_str());
Err(())
}
}