program SVNZero; uses {$IFDEF UNIX}cthreads,{$ENDIF} Interfaces, // this includes the LCL widgetset Classes, SysUtils, CustApp, USubversion, USvnZero, UTestCases, UExecute, UTestCase; type { TSvnZeroApp } TSvnZeroApp = class(TCustomApplication) protected procedure DoRun; override; private procedure NormalRun; public SvnZero: TSvnZero; constructor Create(TheOwner: TComponent); override; destructor Destroy; override; procedure WriteHelp; virtual; end; { TSvnZeroApp } procedure TSvnZeroApp.DoRun; var I: Integer; begin if HasOption('print') then begin SvnZero.PrintOutput := True; end; if HasOption('t', 'test') then begin with TTestCases.Create do try AddNew('Add', TTestCaseAdd); AddNew('Update', TTestCaseUpdate); AddNew('Modify', TTestCaseModify); AddNew('Delete', TTestCaseDelete); AddNew('Merge', TTestCaseMerge); AddNew('Update multiple', TTestCaseUpdateMultiple); AddNew('Delete update', TTestCaseDeleteUpdate); AddNew('Delete update duplicate files', TTestCaseDeleteUpdateDuplicateFiles); for I := 0 to Count - 1 do if Items[I] is TTestCaseSvn then begin TTestCaseSvn(Items[I]).Subversion.PrintOutput := SvnZero.PrintOutput; TTestCaseSvn(Items[I]).Subversion.PrintCommand := SvnZero.PrintOutput; end; Run; finally Free; end; end else begin NormalRun; end; (* // 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; *) // stop program loop Terminate; end; procedure TSvnZeroApp.NormalRun; var Params: TStringArray; I: Integer; J: Integer; begin Params := Default(TStringArray); SetLength(Params, ParamCount); J := 0; for I := 0 to ParamCount - 1 do begin if GetParams(I + 1) <> '--print' then begin Params[J] := GetParams(I + 1); Inc(J); end; end; SetLength(Params, J); SVNZero.ExecuteOutput(Params); end; constructor TSvnZeroApp.Create(TheOwner: TComponent); begin inherited; StopOnException := True; SvnZero := TSvnZero.Create; end; destructor TSvnZeroApp.Destroy; begin FreeAndNil(SvnZero); inherited; end; procedure TSvnZeroApp.WriteHelp; begin { add your help code here } WriteLn('Usage: ', ExeName, ' -h'); end; {$if declared(UseHeapTrace)} const HeapTraceLog = 'heaptrclog.trc'; {$ENDIF} var Application: TSvnZeroApp; {$R *.res} begin {$if declared(UseHeapTrace)} DeleteFile(ExtractFilePath(ParamStr(0)) + HeapTraceLog); SetHeapTraceOutput(ExtractFilePath(ParamStr(0)) + HeapTraceLog); {$ENDIF} Application := TSvnZeroApp.Create(nil); Application.Title := 'SVN Zero'; Application.Run; Application.Free; end.