Skip to content

Commit

Permalink
Fixed #16 and #17 and also made the IsOptionFile work with command mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentparrett committed Feb 24, 2023
1 parent 94b8575 commit 19fdd9a
Show file tree
Hide file tree
Showing 3 changed files with 565 additions and 646 deletions.
18 changes: 12 additions & 6 deletions Src/VSoft.CommandLine.CommandDef.pas
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ TCommandDefImpl = class(TInterfacedObject, ICommandDefinition)
function TryGetOption(const name : string; var option : IOptionDefinition) : boolean;
procedure Clear;
procedure GetAllRegisteredOptions(const list : TList<IOptionDefinition>);
procedure EmumerateCommandOptions(const proc : TConstProc<string,string, string>);overload;
procedure EmumerateCommandOptions(const proc : TConstProc<IOptionDefinition>);overload;
procedure EnumerateCommandOptions(const proc : TConstProc<string,string, string>);overload;
procedure EnumerateCommandOptions(const proc : TConstProc<IOptionDefinition>);overload;

public
constructor Create(const name : string; const alias : string; const usage : string; const description : string; const helpText : string; const visible : boolean; const isDefault : boolean = false);
Expand Down Expand Up @@ -100,7 +100,7 @@ destructor TCommandDefImpl.Destroy;
inherited;
end;

procedure TCommandDefImpl.EmumerateCommandOptions(const proc: TConstProc<IOptionDefinition>);
procedure TCommandDefImpl.EnumerateCommandOptions(const proc: TConstProc<IOptionDefinition>);
var
optionList : TList<IOptionDefinition>;
opt : IOptionDefinition;
Expand All @@ -117,13 +117,16 @@ procedure TCommandDefImpl.EmumerateCommandOptions(const proc: TConstProc<IOption
end));

for opt in optionList do
proc(opt);
begin
if not opt.Hidden then
proc(opt);
end;
finally
optionList.Free;
end;
end;

procedure TCommandDefImpl.EmumerateCommandOptions(const proc: TConstProc<string, string, string>);
procedure TCommandDefImpl.EnumerateCommandOptions(const proc: TConstProc<string, string, string>);
var
optionList : TList<IOptionDefinition>;
opt : IOptionDefinition;
Expand All @@ -140,7 +143,10 @@ procedure TCommandDefImpl.EmumerateCommandOptions(const proc: TConstProc<string,
end));

for opt in optionList do
proc(opt.LongName,opt.ShortName, opt.HelpText);
begin
if not opt.Hidden then
proc(opt.LongName,opt.ShortName, opt.HelpText);
end;
finally
optionList.Free;
end;
Expand Down
Loading

0 comments on commit 19fdd9a

Please sign in to comment.