Do not panic if command line have unreconginzed option.

Return 1 if no command is parsed.
This commit is contained in:
2022-05-24 03:03:36 +00:00
committed by GitHub
parent cccda23664
commit 5ccbfecb89
3 changed files with 4 additions and 2 deletions

1
.gitignore vendored
View File

@@ -2,3 +2,4 @@
/proc_macros/target
.vscode/
test/
.workspace/

View File

@@ -112,7 +112,7 @@ impl Main {
pub fn run(&mut self) -> i32 {
self.cmd = opts::parse_cmd();
if self.cmd.is_none() {
return 0;
return 1;
}
let cmd = self.cmd.as_ref().unwrap();
self.settings = Some(SettingStore::default());

View File

@@ -191,7 +191,8 @@ pub fn parse_cmd() -> Option<CommandOpts> {
let result = match opts.parse(&argv[1..]) {
Ok(m) => m,
Err(err) => {
panic!("{}", err.to_string())
println!("{}", err.to_string());
return None;
}
};
if result.opt_present("h") || result.free.len() == 0 {