Skip to content

Commit

Permalink
Added version
Browse files Browse the repository at this point in the history
  • Loading branch information
hunsche committed Apr 6, 2019
1 parent 3b07ef2 commit 91c3683
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 11 deletions.
3 changes: 2 additions & 1 deletion DelphiDocker.dpk
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ contains
Command.Message in 'Src\Command\Command.Message.pas',
Docker.Utils in 'Src\Docker\Docker.Utils.pas',
Wrapper.Docker in 'Src\Wrapper\Wrapper.Docker.pas',
Wrapper.DockerCompose in 'Src\Wrapper\Wrapper.DockerCompose.pas';
Wrapper.DockerCompose in 'Src\Wrapper\Wrapper.DockerCompose.pas',
Docker.RunWithDocker in 'Src\Docker\Docker.RunWithDocker.pas';

end.
1 change: 1 addition & 0 deletions DelphiDocker.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
<DCCReference Include="Src\Docker\Docker.Utils.pas"/>
<DCCReference Include="Src\Wrapper\Wrapper.Docker.pas"/>
<DCCReference Include="Src\Wrapper\Wrapper.DockerCompose.pas"/>
<DCCReference Include="Src\Docker\Docker.RunWithDocker.pas"/>
<BuildConfiguration Include="Release">
<Key>Cfg_2</Key>
<CfgParent>Base</CfgParent>
Expand Down
25 changes: 17 additions & 8 deletions Src/Command/Command.Runner.pas
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ interface
uses
DOSCommand, OpenToolApi.CommandMessage;

function Runner(ACommand, APath: string): Cardinal;
function Runner(APath, ACommand: string): Integer; overload;
function Runner(ACommand: string): Integer; overload;

implementation

Expand All @@ -15,33 +16,41 @@ implementation
var
FMonitorLock: TObject;

function Runner(ACommand, APath: string): Cardinal;
function DoRunner(APath, ACommand: string): Integer;
var
LDosCommand: TDosCommand;
begin
System.TMonitor.Enter(FMonitorLock);
//System.TMonitor.Enter(FMonitorLock);
try
LDosCommand := TDosCommand.Create(nil);
try
LDosCommand.InputToOutput := False;
// LDosCommand.InputToOutput := False;
LDosCommand.CurrentDir := APath;
LDosCommand.CommandLine := ACommand;
LDosCommand.Execute;

while LDosCommand.IsRunning do
begin
Application.ProcessMessages;
Sleep(0);
end;

Result := LDosCommand.ExitCode

Result := LDosCommand.ExitCode;
finally
LDosCommand.Free;
end;
finally
System.TMonitor.Exit(FMonitorLock);
// System.TMonitor.Exit(FMonitorLock);
end;
end;

function Runner(ACommand: string): Integer;
begin
Result := DoRunner('C:/', ACommand);
end;

function Runner(APath, ACommand: string): Integer;
begin
Result := DoRunner(APath, ACommand);
end;

end.
62 changes: 62 additions & 0 deletions Src/Constants/Constants.Version.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
unit Constants.Version;

interface

type

TVersion = class
private
FName: string;
FSemantic: string;
class var FInstance: TVersion;
public
class function GetInstance: TVersion;
class procedure Release;
property Name: string read FName write FName;
property Semantic: string read FSemantic write FSemantic;
constructor Create;
end;

implementation

{ TVersion }

constructor TVersion.Create;
begin
// {$IFDEF CONDITIONALEXPRESSIONS}
{$IFDEF VER330}
FName := 'Rio';
FSemantic := '10.3.0';
{$ENDIF}
{$IFDEF VER331}
FName := 'Rio';
FSemantic := '10.3.1'
{$ENDIF}
// {$IF RTLVersion >= 14.0}
// {$DEFINE HAS_ERROUTPUT}
// {$IFEND}
// {$ENDIF}
// end;
end;

class function TVersion.GetInstance: TVersion;
begin
if not Assigned(FInstance) then
FInstance := TVersion.Create;

Result := FInstance;
end;

class procedure TVersion.Release;
begin
if Assigned(FInstance) then
FInstance.Free;
end;

initialization

finalization

TVersion.Release;

end.
25 changes: 25 additions & 0 deletions Src/Docker/Docker.RunWithDocker.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
unit Docker.RunWithDocker;

interface

type
TRunWithDocker = class
public
procedure Execute;
end;

implementation

uses
Vcl.Dialogs, Command.Runner, Constants.Version;

{ TRunWithDocker }

procedure TRunWithDocker.Execute;
begin
// Runner('dir');
Runner('docker ps');
ShowMessage('Version ' + TVersion.GetInstance.Semantic);
end;

end.
14 changes: 12 additions & 2 deletions Src/OpenToolApi/OpenToolApi.LocalMenuItem.pas
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ TLocalMenuItem = class(TNotifierObject, IOTALocalMenu, IOTAProjectManagerMenu)

implementation

uses
Docker.RunWithDocker;

constructor TLocalMenuItem.Create;
begin
FCaption := 'Run With Docker';
Expand All @@ -69,8 +72,15 @@ constructor TLocalMenuItem.Create;
end;

procedure TLocalMenuItem.Execute(const MenuContextList: IInterfaceList);
begin
ShowMessage('teste');
var
LRunWithDocker: TRunWithDocker;
begin
LRunWithDocker := TRunWithDocker.Create;
try
LRunWithDocker.Execute;
finally
LRunWithDocker.Free;
end;
end;

function TLocalMenuItem.GetCaption: string;
Expand Down

0 comments on commit 91c3683

Please sign in to comment.