diff options
| author | tldr <[email protected]> | 2023-09-26 18:56:53 +0300 | 
|---|---|---|
| committer | tldr <[email protected]> | 2023-09-26 20:04:01 +0300 | 
| commit | 9f3af346b29ade72d3878f7db7daec40693bab4c (patch) | |
| tree | 890bb9a697e59b38d2fd06a9137950d8cdcb5bdf /library/cpp/getopt/small | |
| parent | 3fadd0a33f4d1046f8af4a0ef78d53925a7839d1 (diff) | |
[vcs],only allow --relative=[path], print = for EqOnly options in help
Diffstat (limited to 'library/cpp/getopt/small')
| -rw-r--r-- | library/cpp/getopt/small/last_getopt_opt.h | 2 | ||||
| -rw-r--r-- | library/cpp/getopt/small/last_getopt_opts.cpp | 18 | 
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 c35e0a756e5..2e6437b9dbe 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 939d5d59d26..984927a0387 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(); | 
