Skip to content

Commit 19fdd9a

Browse files
Fixed #16 and #17 and also made the IsOptionFile work with command mode.
1 parent 94b8575 commit 19fdd9a

File tree

3 files changed

+565
-646
lines changed

3 files changed

+565
-646
lines changed

Src/VSoft.CommandLine.CommandDef.pas

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ TCommandDefImpl = class(TInterfacedObject, ICommandDefinition)
3838
function TryGetOption(const name : string; var option : IOptionDefinition) : boolean;
3939
procedure Clear;
4040
procedure GetAllRegisteredOptions(const list : TList<IOptionDefinition>);
41-
procedure EmumerateCommandOptions(const proc : TConstProc<string,string, string>);overload;
42-
procedure EmumerateCommandOptions(const proc : TConstProc<IOptionDefinition>);overload;
41+
procedure EnumerateCommandOptions(const proc : TConstProc<string,string, string>);overload;
42+
procedure EnumerateCommandOptions(const proc : TConstProc<IOptionDefinition>);overload;
4343

4444
public
4545
constructor Create(const name : string; const alias : string; const usage : string; const description : string; const helpText : string; const visible : boolean; const isDefault : boolean = false);
@@ -100,7 +100,7 @@ destructor TCommandDefImpl.Destroy;
100100
inherited;
101101
end;
102102

103-
procedure TCommandDefImpl.EmumerateCommandOptions(const proc: TConstProc<IOptionDefinition>);
103+
procedure TCommandDefImpl.EnumerateCommandOptions(const proc: TConstProc<IOptionDefinition>);
104104
var
105105
optionList : TList<IOptionDefinition>;
106106
opt : IOptionDefinition;
@@ -117,13 +117,16 @@ procedure TCommandDefImpl.EmumerateCommandOptions(const proc: TConstProc<IOption
117117
end));
118118

119119
for opt in optionList do
120-
proc(opt);
120+
begin
121+
if not opt.Hidden then
122+
proc(opt);
123+
end;
121124
finally
122125
optionList.Free;
123126
end;
124127
end;
125128

126-
procedure TCommandDefImpl.EmumerateCommandOptions(const proc: TConstProc<string, string, string>);
129+
procedure TCommandDefImpl.EnumerateCommandOptions(const proc: TConstProc<string, string, string>);
127130
var
128131
optionList : TList<IOptionDefinition>;
129132
opt : IOptionDefinition;
@@ -140,7 +143,10 @@ procedure TCommandDefImpl.EmumerateCommandOptions(const proc: TConstProc<string,
140143
end));
141144

142145
for opt in optionList do
143-
proc(opt.LongName,opt.ShortName, opt.HelpText);
146+
begin
147+
if not opt.Hidden then
148+
proc(opt.LongName,opt.ShortName, opt.HelpText);
149+
end;
144150
finally
145151
optionList.Free;
146152
end;

0 commit comments

Comments
 (0)