oeAware-manager/0005-add-parameter-detection.patch
fly_1997 a776e1d796 add parameter detection
(cherry picked from commit b86f21110880f19a1b23af2e4135ef17f834d7a5)
2025-03-13 20:50:11 +08:00

45 lines
1.1 KiB
Diff

From a0e5625a256fb55e68f1c83ce997e44017e72358 Mon Sep 17 00:00:00 2001
From: fly_1997 <flylove7@outlook.com>
Date: Wed, 5 Mar 2025 23:18:09 +0800
Subject: [PATCH] add parameter detection
---
src/client/arg_parse.cpp | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/client/arg_parse.cpp b/src/client/arg_parse.cpp
index cb97054..afe95d2 100644
--- a/src/client/arg_parse.cpp
+++ b/src/client/arg_parse.cpp
@@ -81,6 +81,8 @@ int ArgParse::InitCmd(int &cmd, int opt)
if (optarg) {
SetArg(optarg);
}
+ } else {
+ return -1;
}
return 0;
}
@@ -120,11 +122,17 @@ int ArgParse::Init(int argc, char *argv[])
break;
}
default: {
- InitCmd(cmd, opt);
+ if (InitCmd(cmd, opt) < 0) {
+ return -1;
+ }
break;
}
}
}
+ for (int i = optind; i < argc; ++i) {
+ ArgError("invalid option [" + std::string(argv[i]) + "].");
+ return -1;
+ }
if (help) {
PrintHelp();
exit(EXIT_SUCCESS);
--
2.33.0