Skip to content

Commit 91c3683

Browse files
committed
Added version
1 parent 3b07ef2 commit 91c3683

File tree

6 files changed

+119
-11
lines changed

6 files changed

+119
-11
lines changed

DelphiDocker.dpk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ contains
4444
Command.Message in 'Src\Command\Command.Message.pas',
4545
Docker.Utils in 'Src\Docker\Docker.Utils.pas',
4646
Wrapper.Docker in 'Src\Wrapper\Wrapper.Docker.pas',
47-
Wrapper.DockerCompose in 'Src\Wrapper\Wrapper.DockerCompose.pas';
47+
Wrapper.DockerCompose in 'Src\Wrapper\Wrapper.DockerCompose.pas',
48+
Docker.RunWithDocker in 'Src\Docker\Docker.RunWithDocker.pas';
4849

4950
end.

DelphiDocker.dproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@
129129
<DCCReference Include="Src\Docker\Docker.Utils.pas"/>
130130
<DCCReference Include="Src\Wrapper\Wrapper.Docker.pas"/>
131131
<DCCReference Include="Src\Wrapper\Wrapper.DockerCompose.pas"/>
132+
<DCCReference Include="Src\Docker\Docker.RunWithDocker.pas"/>
132133
<BuildConfiguration Include="Release">
133134
<Key>Cfg_2</Key>
134135
<CfgParent>Base</CfgParent>

Src/Command/Command.Runner.pas

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ interface
55
uses
66
DOSCommand, OpenToolApi.CommandMessage;
77

8-
function Runner(ACommand, APath: string): Cardinal;
8+
function Runner(APath, ACommand: string): Integer; overload;
9+
function Runner(ACommand: string): Integer; overload;
910

1011
implementation
1112

@@ -15,33 +16,41 @@ implementation
1516
var
1617
FMonitorLock: TObject;
1718

18-
function Runner(ACommand, APath: string): Cardinal;
19+
function DoRunner(APath, ACommand: string): Integer;
1920
var
2021
LDosCommand: TDosCommand;
2122
begin
22-
System.TMonitor.Enter(FMonitorLock);
23+
//System.TMonitor.Enter(FMonitorLock);
2324
try
2425
LDosCommand := TDosCommand.Create(nil);
2526
try
26-
LDosCommand.InputToOutput := False;
27+
// LDosCommand.InputToOutput := False;
2728
LDosCommand.CurrentDir := APath;
2829
LDosCommand.CommandLine := ACommand;
2930
LDosCommand.Execute;
3031

3132
while LDosCommand.IsRunning do
3233
begin
3334
Application.ProcessMessages;
34-
Sleep(0);
3535
end;
3636

37-
Result := LDosCommand.ExitCode
38-
37+
Result := LDosCommand.ExitCode;
3938
finally
4039
LDosCommand.Free;
4140
end;
4241
finally
43-
System.TMonitor.Exit(FMonitorLock);
42+
// System.TMonitor.Exit(FMonitorLock);
4443
end;
4544
end;
4645

46+
function Runner(ACommand: string): Integer;
47+
begin
48+
Result := DoRunner('C:/', ACommand);
49+
end;
50+
51+
function Runner(APath, ACommand: string): Integer;
52+
begin
53+
Result := DoRunner(APath, ACommand);
54+
end;
55+
4756
end.

Src/Constants/Constants.Version.pas

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
unit Constants.Version;
2+
3+
interface
4+
5+
type
6+
7+
TVersion = class
8+
private
9+
FName: string;
10+
FSemantic: string;
11+
class var FInstance: TVersion;
12+
public
13+
class function GetInstance: TVersion;
14+
class procedure Release;
15+
property Name: string read FName write FName;
16+
property Semantic: string read FSemantic write FSemantic;
17+
constructor Create;
18+
end;
19+
20+
implementation
21+
22+
{ TVersion }
23+
24+
constructor TVersion.Create;
25+
begin
26+
// {$IFDEF CONDITIONALEXPRESSIONS}
27+
{$IFDEF VER330}
28+
FName := 'Rio';
29+
FSemantic := '10.3.0';
30+
{$ENDIF}
31+
{$IFDEF VER331}
32+
FName := 'Rio';
33+
FSemantic := '10.3.1'
34+
{$ENDIF}
35+
// {$IF RTLVersion >= 14.0}
36+
// {$DEFINE HAS_ERROUTPUT}
37+
// {$IFEND}
38+
// {$ENDIF}
39+
// end;
40+
end;
41+
42+
class function TVersion.GetInstance: TVersion;
43+
begin
44+
if not Assigned(FInstance) then
45+
FInstance := TVersion.Create;
46+
47+
Result := FInstance;
48+
end;
49+
50+
class procedure TVersion.Release;
51+
begin
52+
if Assigned(FInstance) then
53+
FInstance.Free;
54+
end;
55+
56+
initialization
57+
58+
finalization
59+
60+
TVersion.Release;
61+
62+
end.

Src/Docker/Docker.RunWithDocker.pas

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
unit Docker.RunWithDocker;
2+
3+
interface
4+
5+
type
6+
TRunWithDocker = class
7+
public
8+
procedure Execute;
9+
end;
10+
11+
implementation
12+
13+
uses
14+
Vcl.Dialogs, Command.Runner, Constants.Version;
15+
16+
{ TRunWithDocker }
17+
18+
procedure TRunWithDocker.Execute;
19+
begin
20+
// Runner('dir');
21+
Runner('docker ps');
22+
ShowMessage('Version ' + TVersion.GetInstance.Semantic);
23+
end;
24+
25+
end.

Src/OpenToolApi/OpenToolApi.LocalMenuItem.pas

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ TLocalMenuItem = class(TNotifierObject, IOTALocalMenu, IOTAProjectManagerMenu)
6161

6262
implementation
6363

64+
uses
65+
Docker.RunWithDocker;
66+
6467
constructor TLocalMenuItem.Create;
6568
begin
6669
FCaption := 'Run With Docker';
@@ -69,8 +72,15 @@ constructor TLocalMenuItem.Create;
6972
end;
7073

7174
procedure TLocalMenuItem.Execute(const MenuContextList: IInterfaceList);
72-
begin
73-
ShowMessage('teste');
75+
var
76+
LRunWithDocker: TRunWithDocker;
77+
begin
78+
LRunWithDocker := TRunWithDocker.Create;
79+
try
80+
LRunWithDocker.Execute;
81+
finally
82+
LRunWithDocker.Free;
83+
end;
7484
end;
7585

7686
function TLocalMenuItem.GetCaption: string;

0 commit comments

Comments
 (0)