aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortldr <tldr@yandex-team.com>2023-09-26 18:56:53 +0300
committertldr <tldr@yandex-team.com>2023-09-26 20:04:01 +0300
commit9f3af346b29ade72d3878f7db7daec40693bab4c (patch)
tree890bb9a697e59b38d2fd06a9137950d8cdcb5bdf
parent3fadd0a33f4d1046f8af4a0ef78d53925a7839d1 (diff)
downloadydb-9f3af346b29ade72d3878f7db7daec40693bab4c.tar.gz
[vcs],only allow --relative=[path], print = for EqOnly options in help
-rw-r--r--library/cpp/getopt/small/last_getopt_opt.h2
-rw-r--r--library/cpp/getopt/small/last_getopt_opts.cpp18
2 files changed, 15 insertions, 5 deletions
diff --git a/library/cpp/getopt/small/last_getopt_opt.h b/library/cpp/getopt/small/last_getopt_opt.h
index c35e0a756e..2e6437b9db 100644
--- a/library/cpp/getopt/small/last_getopt_opt.h
+++ b/library/cpp/getopt/small/last_getopt_opt.h
@@ -295,7 +295,7 @@ namespace NLastGetopt {
* @return self
*/
TOpt& DisableSpaceParse() {
- Y_ASSERT(GetHasArg() == OPTIONAL_ARGUMENT);
+ Y_ASSERT(GetHasArg() == OPTIONAL_ARGUMENT || GetHasArg() == REQUIRED_ARGUMENT);
EqParseOnly_ = true;
return *this;
}
diff --git a/library/cpp/getopt/small/last_getopt_opts.cpp b/library/cpp/getopt/small/last_getopt_opts.cpp
index 939d5d59d2..984927a038 100644
--- a/library/cpp/getopt/small/last_getopt_opts.cpp
+++ b/library/cpp/getopt/small/last_getopt_opts.cpp
@@ -300,13 +300,23 @@ namespace NLastGetopt {
const TString& metavar = title.empty() ? metavarDef : title;
if (option->GetHasArg() == OPTIONAL_ARGUMENT) {
- result << " [" << metavar;
+ if (option->IsEqParseOnly()) {
+ result << "[=";
+ } else {
+ result << " [";
+ }
+ result << metavar;
if (option->HasOptionalValue())
result << ':' << option->GetOptionalValue();
result << ']';
- } else if (option->GetHasArg() == REQUIRED_ARGUMENT)
- result << ' ' << metavar;
- else
+ } else if (option->GetHasArg() == REQUIRED_ARGUMENT) {
+ if (option->IsEqParseOnly()) {
+ result << "=";
+ } else {
+ result << " ";
+ }
+ result << metavar;
+ } else
Y_ASSERT(option->GetHasArg() == NO_ARGUMENT);
return result.Str();