main: accept -h as an alias for --help

This is a widely-used convention, and it's not very helpful to just
print "Unrecognized argument: -h". We won't be able to use -h as a short
argument name for anything else, but that seems like a reasonable
tradeoff.

BUG=b:3739371
TEST=crosvm -h
TEST=crosvm run -h

Change-Id: I6eef06bfd3cf526e54a6904e5085789566dcc958
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3739372
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
Daniel Verkamp 2022-07-01 13:08:56 -07:00 committed by Chromeos LUCI
parent 3ccb636365
commit eb4bfb26e0

View file

@ -425,6 +425,7 @@ fn crosvm_main() -> std::result::Result<CommandStatus, ()> {
eprintln!("Please use `--balloon-bias-mib` instead"); eprintln!("Please use `--balloon-bias-mib` instead");
args.push("--balloon-bias-mib".to_string()); args.push("--balloon-bias-mib".to_string());
} }
"-h" => args.push("--help".to_string()),
arg if arg.starts_with("--") => { arg if arg.starts_with("--") => {
// Split `--arg=val` into `--arg val`, since argh doesn't support the former. // Split `--arg=val` into `--arg val`, since argh doesn't support the former.
if let Some((key, value)) = arg.split_once("=") { if let Some((key, value)) = arg.split_once("=") {