You've already forked lazarus-ccr
Added some methods to the command line reader for gir2pascal to assign tags to command line parameters.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2496 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -46,9 +46,16 @@ type
|
||||
// read from commandline
|
||||
procedure ReadOptions;
|
||||
|
||||
// string based
|
||||
function HasOption(AName: String): Boolean;
|
||||
function OptionValue(AName:String): String;
|
||||
function OptionValues(AName: String): TStrings;
|
||||
|
||||
// tag based
|
||||
function HasOption(AIdentifier: Integer): Boolean;
|
||||
function OptionValue(AIdentifier: Integer): String;
|
||||
function OptionValues(AIdentifier: Integer): TStrings;
|
||||
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
function PrintHelp(MaxLineWidth: Integer): TStrings; virtual;
|
||||
@ -287,6 +294,44 @@ begin
|
||||
Result.Add(S);
|
||||
end;
|
||||
|
||||
function TCommandLineOptions.HasOption(AIdentifier: Integer): Boolean;
|
||||
var
|
||||
Opt: TOption;
|
||||
begin
|
||||
Result := False;
|
||||
Opt := FindOptionByIdentifier(AIdentifier);
|
||||
if Opt = nil then
|
||||
Exit;
|
||||
|
||||
Result := Opt.Present;
|
||||
end;
|
||||
|
||||
function TCommandLineOptions.OptionValue(AIdentifier: Integer): String;
|
||||
var
|
||||
Opt: TOption;
|
||||
begin
|
||||
Result := '';
|
||||
Opt := FindOptionByIdentifier(AIdentifier);
|
||||
if Opt = nil then
|
||||
Exit;
|
||||
|
||||
Result := Opt.Value;
|
||||
end;
|
||||
|
||||
function TCommandLineOptions.OptionValues(AIdentifier: Integer): TStrings;
|
||||
var
|
||||
Opt: TOption;
|
||||
Tmp: String;
|
||||
begin
|
||||
Result := TStringList.Create;
|
||||
Opt := FindOptionByIdentifier(AIdentifier);
|
||||
if Opt = nil then
|
||||
Exit;
|
||||
|
||||
for Tmp in Opt.Values do
|
||||
Result.Add(Tmp);
|
||||
end;
|
||||
|
||||
constructor TCommandLineOptions.Create;
|
||||
begin
|
||||
FOptions := TObjectList.create(True);
|
||||
|
@ -323,7 +323,12 @@ begin
|
||||
ConsoleWidth:=w.ws_col;
|
||||
{$ENDIF}
|
||||
Writeln('Usage: ',ExtractFileName(ParamStr(0)),' [options] -i filename');
|
||||
WriteLn(FCmdOptions.PrintHelp(ConsoleWidth).Text);
|
||||
with FCmdOptions.PrintHelp(ConsoleWidth) do
|
||||
begin
|
||||
WriteLn(Text);
|
||||
Free;
|
||||
|
||||
end;
|
||||
{
|
||||
Writeln('');
|
||||
writeln(' Usage: ',ExtractFileName(ParamStr(0)),' [options] -i filename');
|
||||
|
Reference in New Issue
Block a user