Skip to content

Commit 836b710

Browse files
Improved reporting of missing unnamed parameters
1 parent 2b43346 commit 836b710

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

Src/VSoft.CommandLine.Parser.pas

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ procedure TCommandLineParser.InternalValidate(const parseResult: IInternalParseR
316316
begin
317317
if not (option as IOptionDefInvoke).WasFound then
318318
begin
319-
parseResult.AddError('Required Option [' + option.LongName + '] was not specified');
319+
parseResult.AddError('Required option [' + option.LongName + '] was not specified');
320320
end;
321321
end;
322322
end;
@@ -327,21 +327,33 @@ procedure TCommandLineParser.InternalValidate(const parseResult: IInternalParseR
327327
begin
328328
if not (option as IOptionDefInvoke).WasFound then
329329
begin
330-
parseResult.AddError('Missing required unnamed parameter(s)');
330+
parseResult.AddError('Required parameter <' + option.ShortName + '> was not specified');
331331
Break;
332332
end;
333333
end;
334334
end;
335335

336336
if parseResult.command <> nil then
337337
begin
338+
for option in parseResult.command.RegisteredUnamedOptions do
339+
begin
340+
if option.Required then
341+
begin
342+
if not (option as IOptionDefInvoke).WasFound then
343+
begin
344+
parseResult.AddError('Required parameter <' + option.ShortName + '> was not specified');
345+
Break;
346+
end;
347+
end;
348+
end;
349+
338350
for option in parseResult.command.RegisteredOptions do
339351
begin
340352
if option.Required then
341353
begin
342354
if not (option as IOptionDefInvoke).WasFound then
343355
begin
344-
parseResult.AddError('Required Option [' + option.LongName + '] was not specified');
356+
parseResult.AddError('Required option [' + option.LongName + '] was not specified');
345357
end;
346358
end;
347359
end;

0 commit comments

Comments
 (0)