@@ -159,6 +159,41 @@ TClientCommand::TOptsParseOneLevelResult::TOptsParseOneLevelResult(TConfig& conf
159
159
Init (config.Opts , _argc, const_cast <const char **>(config.ArgV ));
160
160
}
161
161
162
+ void TClientCommand::CheckForExecutableOptions (TConfig& config) {
163
+ int argc = 1 ;
164
+
165
+ while (argc < config.ArgC && config.ArgV [argc][0 ] == ' -' ) {
166
+ const NLastGetopt::TOpt* opt = nullptr ;
167
+ TStringBuf optName (config.ArgV [argc]);
168
+ auto eqPos = optName.find (' =' );
169
+ optName = optName.substr (0 , eqPos);
170
+ if (optName.StartsWith (" --" )) {
171
+ opt = config.Opts ->FindLongOption (optName.substr (2 ));
172
+ } else {
173
+ if (optName.length () > 2 ) {
174
+ // Char option list
175
+ if (eqPos != TStringBuf::npos) {
176
+ throw yexception () << " Char option list " << optName << " can not be followed by \" =\" sign" ;
177
+ }
178
+ } else if (optName.length () == 2 ) {
179
+ // Single char option
180
+ opt = config.Opts ->FindCharOption (optName[1 ]);
181
+ } else {
182
+ throw yexception () << " Wrong CLI argument \" " << optName << " \" " ;
183
+ }
184
+ }
185
+ if (config.ExecutableOptions .find (optName) != config.ExecutableOptions .end ()) {
186
+ config.HasExecutableOptions = true ;
187
+ }
188
+ if (opt != nullptr && opt->GetHasArg () != NLastGetopt::NO_ARGUMENT) {
189
+ if (eqPos == TStringBuf::npos) {
190
+ ++argc;
191
+ }
192
+ }
193
+ ++argc;
194
+ }
195
+ }
196
+
162
197
void TClientCommand::Config (TConfig& config) {
163
198
config.Opts = &Opts;
164
199
config.OnlyExplicitProfile = OnlyExplicitProfile;
@@ -197,6 +232,7 @@ void TClientCommand::Prepare(TConfig& config) {
197
232
config.ArgsSettings = TConfig::TArgSettings ();
198
233
config.Opts = &Opts;
199
234
Config (config);
235
+ CheckForExecutableOptions (config);
200
236
config.CheckParamsCount ();
201
237
SetCustomUsage (config);
202
238
SaveParseResult (config);
0 commit comments