-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmokarra.lpr
253 lines (217 loc) · 6.32 KB
/
mokarra.lpr
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
{*****************************************************************************}
{ _ }
{ /\/\ ___ | | ____ _ _ __ _ __ __ _ }
{ / \ / _ \| |/ / _` | '__| '__/ _` | }
{ / /\/\ \ (_) | < (_| | | | | | (_| | }
{ \/ \/\___/|_|\_\__,_|_| |_| \__,_| }
{ }
{ Mokarra }
{ (C)opyright 2011-2015 - LeafScale Systems, Inc. }
{ }
{ This software is protected under the LeafScale Software License }
{ }
{*****************************************************************************}
{ /mokarra.lpr }
{ Main Program Executable / Main Lazarus Project }
{*****************************************************************************}
program mokarra;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes, SysUtils, CustApp, Crt, UriParser,
ConfigFile, ConfigMenu, SystemInfo,
ReefIndex, ReefRepo, PkgSrc, Version;
type
{ TMokarra }
TMokarra = class(TCustomApplication)
protected
procedure DoRun; override;
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
procedure WriteBanner; virtual;
procedure WriteHelp; virtual;
end;
var
QuietOutput : BOOLEAN = False;
VerboseOutput : BOOLEAN = False;
{ TMokarra }
procedure TMokarra.DoRun;
var
ErrorMsg : String;
//Cfg : MasterConfig;
ParseValue : String;
begin
// quick check parameters
ErrorMsg:=CheckOptions('hQvVcsit','help quiet version verbose config sysinfo index test');
if ErrorMsg<>'' then begin
ShowException(Exception.Create(ErrorMsg));
Terminate;
Exit;
end;
if HasOption('Q','quiet') then begin
QuietOutput := True;
end;
WriteBanner;
if (self.ParamCount = 0 ) then begin
WriteHelp;
Terminate;
Exit;
end;
if HasOption('h','help') then begin
WriteHelp;
Terminate;
Exit;
end;
if HasOption('s','sysinfo') then begin
SystemDisplayInfo();
Terminate;
Exit;
end;
if HasOption('v','version') then begin
writeln('Mokarra Version = ', MOKARRA_VERSION);
writeln(' Build Release = ', MOKARRA_RELEASE);
Terminate;
Exit;
end;
if HasOption('p','pkginfo') then begin
//ParseValue := GetOptionValue('p','parse');
//ParsePkgSrcFile(ParseValue+ '.pkgsrc');
Terminate;
Exit;
end;
if HasOption('i','index') then begin
BuildReefIndex;
Terminate;
Exit;
end;
if HasOption('c','config') then begin
ConfigMenuMain();
Terminate;
Exit;
end;
if HasOption('V','verbose') then begin
VerboseOutput := True;
if (VerboseOutput = True) then
writeln('Verbose Mode = ON');
end;
{ add your program here }
// stop program loop
Terminate;
end;
constructor TMokarra.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
StopOnException:=True;
end;
destructor TMokarra.Destroy;
begin
inherited Destroy;
end;
{* Display the program banner *}
procedure TMokarra.WriteBanner;
begin
if (QuietOutput = False) then
begin
TextColor(LightCyan);
write('M');
TextColor(Cyan);
write('okarra ');
TextColor(LightCyan);
write('v');
TextColor(Cyan);
write(MOKARRA_VERSION);
TextColor(DarkGray);
write(' : (');
TextColor(LightGray);
write('C');
TextColor(DarkGray);
write(')opyright');
TextColor(DarkGray);
write(' 2015, ');
TextColor(LightBlue);
write('LeafScale, Inc. ');
TextColor(DarkGray);
write('[');
TextColor(Blue);
write('http://www.leafscale.com');
TextColor(DarkGray);
write(']');
TextColor(LightGray);
writeln();
end;
end;
{* Display the program help *}
procedure TMokarra.WriteHelp;
begin
TextColor(LightGray);
write('Usage: ');
TextColor(White);
write(ExeName);
TextColor(Yellow);
write(' [option]');
TextColor(LightGray);
writeln();
writeln();
TextColor(LightBlue); write(' -c ');
TextColor(DarkGray); write('|');
TextColor(LightBlue); write(' --config');
TextColor(DarkGray); write(' : ');
TextColor(LightGray); write('configure');
writeln();
TextColor(LightBlue); write(' -s ');
TextColor(DarkGray); write('|');
TextColor(LightBlue); write(' --sysinfo');
TextColor(DarkGray); write(' : ');
TextColor(LightGray); write('display sysinfo');
writeln();
TextColor(LightBlue); write(' -Q ');
TextColor(DarkGray); write('|');
TextColor(LightBlue); write(' --quiet');
TextColor(DarkGray); write(' : ');
TextColor(LightGray); write('quiet mode');
writeln();
TextColor(LightBlue); write(' -V ');
TextColor(DarkGray); write('|');
TextColor(LightBlue); write(' --verbose');
TextColor(DarkGray); write(' : ');
TextColor(LightGray); write('verbose mode');
(*
writeln();
TextColor(LightBlue); write(' -p ');
TextColor(DarkGray); write('|');
TextColor(LightBlue); write(' --parse=');
TextColor(DarkGray); write(' : ');
TextColor(LightGray); write('parse pkgsrc [filename]');
writeln();
TextColor(LightBlue); write(' -r ');
TextColor(DarkGray); write('|');
TextColor(LightBlue); write(' --rebuild');
TextColor(DarkGray); write(' : ');
TextColor(LightGray); write('rebuild reef index');
*)
writeln();
TextColor(LightBlue); write(' -i ');
TextColor(DarkGray); write('|');
TextColor(LightBlue); write(' --index');
TextColor(DarkGray); write(' : ');
TextColor(LightGray); write('build reef index');
writeln();
TextColor(LightBlue); write(' -v ');
TextColor(DarkGray); write('|');
TextColor(LightBlue); write(' --version');
TextColor(DarkGray); write(' : ');
TextColor(LightGray); write('display version');
writeln();
end;
var
Application: TMokarra;
{$IFDEF WINDOWS}{$R mokarra.rc}{$ENDIF}
begin
Application:=TMokarra.Create(nil);
Application.Title:='Mokarra';
Application.Run;
Application.Free;
end.