-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpostproc.pp
More file actions
82 lines (67 loc) · 2.27 KB
/
Copy pathpostproc.pp
File metadata and controls
82 lines (67 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
program postproc;
{$mode objfpc}
{$h+}
uses classes, types, custapp, htmlpp;
type
{ TPostProcessorApp }
TPostProcessorApp = class(TCustomApplication)
private
FProcessor : THTMLPostProcessor;
procedure DoProcessorLog(sender: TObject; const Msg: string);
procedure Usage(const Msg: string);
protected
procedure DoRun; override;
public
constructor create(aOwner : TComponent); override;
end;
{ THTMLPostProcessor }
procedure TPostProcessorApp.DoProcessorLog(sender: TObject; const Msg: string);
begin
Writeln(Msg);
end;
constructor TPostProcessorApp.create(aOwner: TComponent);
begin
Inherited create(aOwner);
FProcessor:=THTMLPostProcessor.Create(Self);
end;
procedure TPostProcessorApp.Usage(const Msg : string);
begin
if Msg<>'' then
Writeln('Error: ',Msg);
Writeln('Usage ',ExeName,' [options]');
Writeln('Where options is one or more of:');
Writeln('-h --help this page');
Writeln('-b --base-dir=DIR directory to use as base dir for all relative names.');
Writeln('-c --backup create a backup of each processed file.');
Writeln('-d --directory=DIR a directory with HTML files to process. This option can be specified multiple times.');
Writeln('-n --new-issue-url=URL the URL to report a new issue');
Writeln('-t --timestamp add timestamp to page footer');
Writeln('-r --recurse recurse into subdirectories');
ExitCode:=Ord(Msg<>'');
end;
procedure TPostProcessorApp.DoRun;
var
lErr : String;
begin
Terminate;
lErr:=checkoptions('hvtcrd:n:b:',['help','directory:','new-issue-url:','base-dir:','verbose','timestamp','backup','recurse']);
if lErr<>'' then
Usage(lErr);
FProcessor.Dirs:=GetOptionValues('d','directory');
FProcessor.NewIssueURL:=GetOptionValue('i','issue-url');
FProcessor.BaseDir:=GetOptionValue('b','base-dir');
FProcessor.TimeStamp:=HasOption('t','timestamp');
FProcessor.Backup:=HasOption('c','backup');
FProcessor.Recurse:=HasOption('r','recurse');
if hasOption('v','verbose') then
FProcessor.OnLog:=@DoProcessorLog;
FProcessor.Execute;
end;
var
Application : TPostProcessorApp;
begin
Application:=TPostProcessorApp.Create(Nil);
Application.Initialize;
Application.Run;
Application.Free;
end.