mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-12 05:18:43 +00:00
Remove unnecessary manual CLI parsing
This commit is contained in:
@@ -229,24 +229,16 @@ fn wasmer_main_inner() -> Result<(), anyhow::Error> {
|
|||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
let command = args.get(1);
|
|
||||||
let options = if cfg!(target_os = "linux") && binpath.ends_with("wasmer-binfmt-interpreter") {
|
let options = if cfg!(target_os = "linux") && binpath.ends_with("wasmer-binfmt-interpreter") {
|
||||||
WasmerCLIOptions::Run(Run::from_binfmt_args())
|
WasmerCLIOptions::Run(Run::from_binfmt_args())
|
||||||
} else {
|
} else {
|
||||||
match command.unwrap_or(&"".to_string()).as_ref() {
|
match WasmerCLIOptions::try_parse_from(args.iter()) {
|
||||||
"add" | "cache" | "compile" | "config" | "create-obj" | "create-exe" | "help"
|
Ok(o) => o,
|
||||||
| "inspect" | "init" | "run" | "self-update" | "validate" | "wast" | "binfmt"
|
Err(e) => {
|
||||||
| "list" | "login" | "publish" => WasmerCLIOptions::parse(),
|
|
||||||
_ => {
|
|
||||||
WasmerCLIOptions::try_parse_from(args.iter()).unwrap_or_else(|e| {
|
|
||||||
match e.kind() {
|
match e.kind() {
|
||||||
// This fixes a issue that:
|
|
||||||
// 1. Shows the version twice when doing `wasmer -V`
|
|
||||||
// 2. Shows the run help (instead of normal help) when doing `wasmer --help`
|
|
||||||
ErrorKind::DisplayVersion | ErrorKind::DisplayHelp => e.exit(),
|
ErrorKind::DisplayVersion | ErrorKind::DisplayHelp => e.exit(),
|
||||||
_ => WasmerCLIOptions::Run(Run::parse()),
|
_ => WasmerCLIOptions::Run(Run::parse()),
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user