mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-15 17:49:25 +02:00
* Small improvements, quiet mode
This commit is contained in:
parent
173233d78e
commit
5bcedcfe30
@ -11,7 +11,10 @@ type
|
|||||||
{ TDPK2LPKApplication }
|
{ TDPK2LPKApplication }
|
||||||
|
|
||||||
TDPK2LPKApplication = class(TCustomApplication)
|
TDPK2LPKApplication = class(TCustomApplication)
|
||||||
|
private
|
||||||
|
procedure WriteLog(const Msg: String);
|
||||||
protected
|
protected
|
||||||
|
FQuiet : Boolean;
|
||||||
procedure DoRun; override;
|
procedure DoRun; override;
|
||||||
public
|
public
|
||||||
constructor Create(TheOwner: TComponent); override;
|
constructor Create(TheOwner: TComponent); override;
|
||||||
@ -22,11 +25,18 @@ type
|
|||||||
|
|
||||||
{ TDPK2LPKApplication }
|
{ TDPK2LPKApplication }
|
||||||
|
|
||||||
|
procedure TDPK2LPKApplication.WriteLog(Const Msg : String);
|
||||||
|
|
||||||
|
begin
|
||||||
|
if FQuiet then Exit;
|
||||||
|
Writeln(StdErr,Msg);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TDPK2LPKApplication.DoRun;
|
procedure TDPK2LPKApplication.DoRun;
|
||||||
|
|
||||||
const
|
const
|
||||||
Short = 'ho:k:u';
|
Short = 'ho:k:uq';
|
||||||
Long : Array of string = ('help','output:','known:','update');
|
Long : Array of string = ('help','output:','known:','update','quiet');
|
||||||
|
|
||||||
var
|
var
|
||||||
ErrorMsg: String;
|
ErrorMsg: String;
|
||||||
@ -48,7 +58,9 @@ begin
|
|||||||
Usage('Need one or more input files');
|
Usage('Need one or more input files');
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
FQuiet:=HasOption('q','quiet');
|
||||||
OFN:=GetOptionValue('o','output');
|
OFN:=GetOptionValue('o','output');
|
||||||
|
|
||||||
if (OFN<>'') and (Length(FNS)>1) then
|
if (OFN<>'') and (Length(FNS)>1) then
|
||||||
begin
|
begin
|
||||||
Usage('Cannot specify output file with more than one input file');
|
Usage('Cannot specify output file with more than one input file');
|
||||||
@ -64,7 +76,13 @@ begin
|
|||||||
if (OFN='') then
|
if (OFN='') then
|
||||||
OFN:=ChangeFileExt(PFN,'.lpk');
|
OFN:=ChangeFileExt(PFN,'.lpk');
|
||||||
CNV.UpdateKnown:=HasOption('u','update');
|
CNV.UpdateKnown:=HasOption('u','update');
|
||||||
CNV.Convert(PFN,OFN);
|
WriteLog(Format('Converting %s to %s',[PFN,OFN]));
|
||||||
|
try
|
||||||
|
CNV.Convert(PFN,OFN);
|
||||||
|
except
|
||||||
|
On E : Exception do
|
||||||
|
WriteLog(Format('Error %s Converting %s to %s : %s',[E.ClassName,PFN,OFN,E.MEssage]));
|
||||||
|
end;
|
||||||
OFN:='';
|
OFN:='';
|
||||||
end;
|
end;
|
||||||
if HasOption('u','update') and (KFN<>'') then
|
if HasOption('u','update') and (KFN<>'') then
|
||||||
@ -87,10 +105,16 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDPK2LPKApplication.Usage(Const Msg : String);
|
procedure TDPK2LPKApplication.Usage(Const Msg : String);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if Msg<>'' then
|
if Msg<>'' then
|
||||||
Writeln('Error: ',Msg);
|
Writeln('Error: ',Msg);
|
||||||
Writeln('Usage: ',ExeName, ' [options] File1 [File2]');
|
Writeln('Usage: ',ExeName, ' [options] File1 [File2]');
|
||||||
|
Writeln('Where [options] is one or more of:');
|
||||||
|
Writeln('-h --help this help');
|
||||||
|
Writeln('-k --known=FILE File with known packages, which can be added to requires if encountered');
|
||||||
|
Writeln('-q --quiet Produce less output');
|
||||||
|
Writeln('-u --update Add processed packages to known packages file');
|
||||||
ExitCode:=Ord(Msg<>'');
|
ExitCode:=Ord(Msg<>'');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -365,6 +365,7 @@ Var
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
Parser:=nil;
|
Parser:=nil;
|
||||||
|
El:=Nil;
|
||||||
C:=TPackageContainer.Create;
|
C:=TPackageContainer.Create;
|
||||||
try
|
try
|
||||||
Parser:=TSimpleParser.Create;
|
Parser:=TSimpleParser.Create;
|
||||||
|
Loading…
Reference in New Issue
Block a user