Made commandline more verbose
This commit is contained in:
parent
c9b6b19479
commit
b2ff58af6e
51
UApp.pas
51
UApp.pas
|
@ -49,6 +49,8 @@ type
|
||||||
FLineFilters: TLineFilters;
|
FLineFilters: TLineFilters;
|
||||||
FCurrentLineFilter: TLineFilter;
|
FCurrentLineFilter: TLineFilter;
|
||||||
FCommandMatcher: TRegExpr;
|
FCommandMatcher: TRegExpr;
|
||||||
|
FCommandFileName: String;
|
||||||
|
FLogFileName: String;
|
||||||
procedure DoRun; override;
|
procedure DoRun; override;
|
||||||
procedure ProcessCommand(ACommand, AParams: String);
|
procedure ProcessCommand(ACommand, AParams: String);
|
||||||
procedure WriteContent(AContent: String; AFilters: TFilterList;
|
procedure WriteContent(AContent: String; AFilters: TFilterList;
|
||||||
|
@ -87,10 +89,25 @@ var
|
||||||
lineFilter: TLineFilter;
|
lineFilter: TLineFilter;
|
||||||
line: String;
|
line: String;
|
||||||
begin
|
begin
|
||||||
AssignFile(commandFile, ParamStr(1));
|
if HasOption('h', 'help') or not HasOption('c', 'commandfile') then
|
||||||
|
begin
|
||||||
|
WriteHelp;
|
||||||
|
Terminate;
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
FCommandFileName := GetOptionValue('c', 'commandfile');
|
||||||
|
|
||||||
|
if not FileExists(FCommandFileName) then
|
||||||
|
begin
|
||||||
|
Writeln('Commandfile not found: ', FCommandFileName);
|
||||||
|
ExitCode := 1;
|
||||||
|
Terminate;
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
AssignFile(commandFile, FCommandFileName);
|
||||||
Reset(commandFile);
|
Reset(commandFile);
|
||||||
AssignFile(logFile, ParamStr(2));
|
|
||||||
Reset(logFile);
|
|
||||||
|
|
||||||
// Parse command file first
|
// Parse command file first
|
||||||
while not EOF(commandFile) do
|
while not EOF(commandFile) do
|
||||||
|
@ -100,6 +117,19 @@ begin
|
||||||
ProcessCommand(FCommandMatcher.Match[1], FCommandMatcher.Match[3]);
|
ProcessCommand(FCommandMatcher.Match[1], FCommandMatcher.Match[3]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
CloseFile(commandFile);
|
||||||
|
|
||||||
|
if not FileExists(FLogFileName) then
|
||||||
|
begin
|
||||||
|
Writeln('Logfile not found: ', FLogFileName);
|
||||||
|
ExitCode := 1;
|
||||||
|
Terminate;
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
AssignFile(logFile, FLogFileName);
|
||||||
|
Reset(logFile);
|
||||||
|
|
||||||
// Filter log
|
// Filter log
|
||||||
while not EOF(logFile) do
|
while not EOF(logFile) do
|
||||||
begin
|
begin
|
||||||
|
@ -111,7 +141,6 @@ begin
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
CloseFile(commandFile); //TODO: narrow scope!
|
|
||||||
CloseFile(logFile);
|
CloseFile(logFile);
|
||||||
|
|
||||||
Terminate;
|
Terminate;
|
||||||
|
@ -132,6 +161,10 @@ begin
|
||||||
highlightFilter := THighlightFilter.Create(AParams);
|
highlightFilter := THighlightFilter.Create(AParams);
|
||||||
FCurrentLineFilter.Filters.Add(highlightFilter);
|
FCurrentLineFilter.Filters.Add(highlightFilter);
|
||||||
end;
|
end;
|
||||||
|
'file':
|
||||||
|
begin
|
||||||
|
FLogFileName := AParams;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -235,7 +268,15 @@ end;
|
||||||
|
|
||||||
procedure TLogFilterApplication.WriteHelp;
|
procedure TLogFilterApplication.WriteHelp;
|
||||||
begin
|
begin
|
||||||
|
Writeln('Usage: ', ExtractFileName(ExeName), ' [options]');
|
||||||
|
Writeln;
|
||||||
|
Writeln('Options:');
|
||||||
|
Writeln(' -c --commandfile=<filename>');
|
||||||
|
Writeln(' specifies the filename with filter commands');
|
||||||
|
Writeln(' -f --logfile=<filename>');
|
||||||
|
Writeln(' specifies the logfile to be parsed');
|
||||||
|
Writeln(' -h --help');
|
||||||
|
Writeln(' show this help screen');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
Loading…
Reference in New Issue