program test;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes, SysUtils, CustApp
{ you can add units after this };
type
{ testcount }
testcount = class(TCustomApplication)
protected
procedure DoRun; override;
public
constructor Create(TheOwner : TComponent); override;
destructor Destroy; override;
procedure WriteHelp; virtual;
end;
{ testcount }
procedure testcount.DoRun;
var
ErrorMsg : String;
begin
// quick check parameters
ErrorMsg := CheckOptions('h', 'help');
if ErrorMsg <> '' then begin
ShowException(Exception.Create(ErrorMsg));
Terminate;
Exit;
end;
// parse parameters
if HasOption('h', 'help') then begin
WriteHelp;
Terminate;
Exit;
end;
{ add your program here }
writeln('hello word');
// stop program loop
Terminate;
end;
constructor testcount.Create(TheOwner : TComponent);
begin
inherited Create(TheOwner);
StopOnException := True;
end;
destructor testcount.Destroy;
begin
inherited Destroy;
end;
procedure testcount.WriteHelp;
begin
{ add your help code here }
writeln('Usage: ', ExeName, ' -h');
end;
var
Application : testcount;
begin
Application := testcount.Create(nil);
Application.Title := 'testcount';
Application.Run;
Application.Free;
end.