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
|
// read from commandline
|
||||||
procedure ReadOptions;
|
procedure ReadOptions;
|
||||||
|
|
||||||
|
// string based
|
||||||
function HasOption(AName: String): Boolean;
|
function HasOption(AName: String): Boolean;
|
||||||
function OptionValue(AName:String): String;
|
function OptionValue(AName:String): String;
|
||||||
function OptionValues(AName: String): TStrings;
|
function OptionValues(AName: String): TStrings;
|
||||||
|
|
||||||
|
// tag based
|
||||||
|
function HasOption(AIdentifier: Integer): Boolean;
|
||||||
|
function OptionValue(AIdentifier: Integer): String;
|
||||||
|
function OptionValues(AIdentifier: Integer): TStrings;
|
||||||
|
|
||||||
constructor Create;
|
constructor Create;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
function PrintHelp(MaxLineWidth: Integer): TStrings; virtual;
|
function PrintHelp(MaxLineWidth: Integer): TStrings; virtual;
|
||||||
@ -287,6 +294,44 @@ begin
|
|||||||
Result.Add(S);
|
Result.Add(S);
|
||||||
end;
|
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;
|
constructor TCommandLineOptions.Create;
|
||||||
begin
|
begin
|
||||||
FOptions := TObjectList.create(True);
|
FOptions := TObjectList.create(True);
|
||||||
|
@ -323,7 +323,12 @@ begin
|
|||||||
ConsoleWidth:=w.ws_col;
|
ConsoleWidth:=w.ws_col;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Writeln('Usage: ',ExtractFileName(ParamStr(0)),' [options] -i filename');
|
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('');
|
||||||
writeln(' Usage: ',ExtractFileName(ParamStr(0)),' [options] -i filename');
|
writeln(' Usage: ',ExtractFileName(ParamStr(0)),' [options] -i filename');
|
||||||
|
Reference in New Issue
Block a user