@@ -133,13 +133,24 @@ TClientCommand::TOptsParseOneLevelResult::TOptsParseOneLevelResult(TConfig& conf
133
133
optName = optName.substr (0 , eqPos);
134
134
if (optName.StartsWith (" --" )) {
135
135
opt = config.Opts ->FindLongOption (optName.substr (2 ));
136
- } else {
137
- opt = config.Opts ->FindCharOption (optName[1 ]);
138
- }
139
- if (opt != nullptr && opt->GetHasArg () != NLastGetopt::NO_ARGUMENT) {
140
- if (eqPos == TStringBuf::npos) {
136
+ if (opt != nullptr && opt->GetHasArg () != NLastGetopt::NO_ARGUMENT && eqPos == TStringBuf::npos) {
141
137
++_argc;
142
138
}
139
+ } else {
140
+ if (optName.length () > 2 ) {
141
+ // Char option list
142
+ if (eqPos != TStringBuf::npos) {
143
+ throw yexception () << " Char option list " << optName << " can not be followed by \" =\" sign" ;
144
+ }
145
+ } else if (optName.length () == 2 ) {
146
+ // Single char option
147
+ opt = config.Opts ->FindCharOption (optName[1 ]);
148
+ if (opt != nullptr && opt->GetHasArg () != NLastGetopt::NO_ARGUMENT && eqPos == TStringBuf::npos) {
149
+ ++_argc;
150
+ }
151
+ } else {
152
+ throw yexception () << " Wrong CLI argument \" " << optName << " \" " ;
153
+ }
143
154
}
144
155
} else {
145
156
--levels;
@@ -149,31 +160,6 @@ TClientCommand::TOptsParseOneLevelResult::TOptsParseOneLevelResult(TConfig& conf
149
160
Init (config.Opts , _argc, const_cast <const char **>(config.ArgV ));
150
161
}
151
162
152
- void TClientCommand::CheckForExecutableOptions (TConfig& config) {
153
- int argc = 1 ;
154
-
155
- while (argc < config.ArgC && config.ArgV [argc][0 ] == ' -' ) {
156
- const NLastGetopt::TOpt* opt = nullptr ;
157
- TStringBuf optName (config.ArgV [argc]);
158
- auto eqPos = optName.find (' =' );
159
- optName = optName.substr (0 , eqPos);
160
- if (optName.StartsWith (" --" )) {
161
- opt = config.Opts ->FindLongOption (optName.substr (2 ));
162
- } else {
163
- opt = config.Opts ->FindCharOption (optName[1 ]);
164
- }
165
- if (config.ExecutableOptions .find (optName) != config.ExecutableOptions .end ()) {
166
- config.HasExecutableOptions = true ;
167
- }
168
- if (opt != nullptr && opt->GetHasArg () != NLastGetopt::NO_ARGUMENT) {
169
- if (eqPos == TStringBuf::npos) {
170
- ++argc;
171
- }
172
- }
173
- ++argc;
174
- }
175
- }
176
-
177
163
void TClientCommand::Config (TConfig& config) {
178
164
config.Opts = &Opts;
179
165
config.OnlyExplicitProfile = OnlyExplicitProfile;
@@ -212,7 +198,6 @@ void TClientCommand::Prepare(TConfig& config) {
212
198
config.ArgsSettings = TConfig::TArgSettings ();
213
199
config.Opts = &Opts;
214
200
Config (config);
215
- CheckForExecutableOptions (config);
216
201
config.CheckParamsCount ();
217
202
SetCustomUsage (config);
218
203
SaveParseResult (config);
0 commit comments