Skip to content

Commit 9aaefd6

Browse files
committed
Resume first version
1 parent 1021e75 commit 9aaefd6

17 files changed

+1241
-597
lines changed

DelphiDocker.dpk

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,12 @@ requires
3434

3535
contains
3636
OpenToolApi.Register in 'Src\OpenToolApi\OpenToolApi.Register.pas',
37-
OpenToolApi.ToolBarItem in 'Src\OpenToolApi\OpenToolApi.ToolBarItem.pas' {ToolBarItem: TDataModule},
3837
Command.Runner in 'Src\Command\Command.Runner.pas',
3938
OpenToolApi.CommandMessage in 'Src\OpenToolApi\OpenToolApi.CommandMessage.pas',
4039
OpenToolApi.LocalMenuItem in 'Src\OpenToolApi\OpenToolApi.LocalMenuItem.pas',
41-
OpenToolApi.Events in 'Src\OpenToolApi\OpenToolApi.Events.pas',
42-
UtilityFunctions in 'Src\OpenToolApi\UtilityFunctions.pas',
43-
Command.Cmd in 'Src\Command\Command.Cmd.pas',
44-
Command.Message in 'Src\Command\Command.Message.pas',
45-
Docker.Utils in 'Src\Docker\Docker.Utils.pas',
46-
Wrapper.Docker in 'Src\Wrapper\Wrapper.Docker.pas',
47-
Wrapper.DockerCompose in 'Src\Wrapper\Wrapper.DockerCompose.pas',
40+
OpenToolApi.Tools in 'Src\OpenToolApi\OpenToolApi.Tools.pas',
4841
Docker.RunWithDocker in 'Src\Docker\Docker.RunWithDocker.pas',
49-
Constants.Version in 'Src\Constants\Constants.Version.pas';
42+
Constants.Version in 'Src\Constants\Constants.Version.pas',
43+
OpenToolApi.MenuItem in 'Src\OpenToolApi\OpenToolApi.MenuItem.pas';
5044

5145
end.

DelphiDocker.dproj

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,23 +114,13 @@
114114
<DCCReference Include="rtl.dcp"/>
115115
<DCCReference Include="designide.dcp"/>
116116
<DCCReference Include="Src\OpenToolApi\OpenToolApi.Register.pas"/>
117-
<DCCReference Include="Src\OpenToolApi\OpenToolApi.ToolBarItem.pas">
118-
<Form>ToolBarItem</Form>
119-
<FormType>dfm</FormType>
120-
<DesignClass>TDataModule</DesignClass>
121-
</DCCReference>
122117
<DCCReference Include="Src\Command\Command.Runner.pas"/>
123118
<DCCReference Include="Src\OpenToolApi\OpenToolApi.CommandMessage.pas"/>
124119
<DCCReference Include="Src\OpenToolApi\OpenToolApi.LocalMenuItem.pas"/>
125-
<DCCReference Include="Src\OpenToolApi\OpenToolApi.Events.pas"/>
126-
<DCCReference Include="Src\OpenToolApi\UtilityFunctions.pas"/>
127-
<DCCReference Include="Src\Command\Command.Cmd.pas"/>
128-
<DCCReference Include="Src\Command\Command.Message.pas"/>
129-
<DCCReference Include="Src\Docker\Docker.Utils.pas"/>
130-
<DCCReference Include="Src\Wrapper\Wrapper.Docker.pas"/>
131-
<DCCReference Include="Src\Wrapper\Wrapper.DockerCompose.pas"/>
120+
<DCCReference Include="Src\OpenToolApi\OpenToolApi.Tools.pas"/>
132121
<DCCReference Include="Src\Docker\Docker.RunWithDocker.pas"/>
133122
<DCCReference Include="Src\Constants\Constants.Version.pas"/>
123+
<DCCReference Include="Src\OpenToolApi\OpenToolApi.MenuItem.pas"/>
134124
<BuildConfiguration Include="Release">
135125
<Key>Cfg_2</Key>
136126
<CfgParent>Base</CfgParent>

Src/Command/Command.Cmd.pas

Lines changed: 0 additions & 79 deletions
This file was deleted.

Src/Command/Command.Message.pas

Lines changed: 0 additions & 63 deletions
This file was deleted.

Src/Command/Command.Runner.pas

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
interface
44

55
uses
6-
DOSCommand, OpenToolApi.CommandMessage, UtilityFunctions, System.Classes;
6+
DOSCommand, OpenToolApi.CommandMessage, OpenToolApi.Tools, System.Classes;
77

88
type
99
TRunnerReturn = record
@@ -20,13 +20,20 @@ implementation
2020
uses
2121
System.SysUtils, Vcl.Forms;
2222

23+
procedure OnReadLine(ASender: TObject; const ANewLine: string; AOutputType: TOutputType);
24+
begin
25+
TCommandMessage.GetInstance.WriteLn(ANewLine);
26+
end;
27+
2328
function DoRunner(APath, ACommand: string): TRunnerReturn;
2429
var
2530
LDosCommand: TDosCommand;
2631
begin
2732
LDosCommand := TDosCommand.Create(nil);
2833
try
29-
LDosCommand.InputToOutput := True;
34+
TCommandMessage.GetInstance.WriteLn(APath + '>' + ACommand);
35+
LDosCommand.OnNewLine := OnReadLine;
36+
LDosCommand.InputToOutput := False;
3037
LDosCommand.CurrentDir := APath;
3138
LDosCommand.CommandLine := ACommand;
3239
LDosCommand.Execute;

Src/Docker/Cmd.pas

Lines changed: 0 additions & 13 deletions
This file was deleted.

Src/Docker/Docker.RunWithDocker.pas

Lines changed: 15 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,69 +3,47 @@
33
interface
44

55
uses
6-
UtilityFunctions, SysUtils;
6+
OpenToolApi.Tools, SysUtils, ToolsAPI;
77

88
type
99
TRunWithDocker = class
1010
const
1111
COMMAND_ERROR = 1;
1212
COMMAND_SUCESS = 0;
1313
public
14-
procedure Execute;
14+
procedure Execute(AProject: IOTAProject);
1515
end;
1616

1717
implementation
1818

1919
uses
20-
Vcl.Dialogs, Command.Runner, Constants.Version, System.Classes;
20+
Vcl.Dialogs, Command.Runner, Constants.Version, System.Classes, Vcl.Menus;
2121

2222
{ TRunWithDocker }
2323

24-
procedure TRunWithDocker.Execute;
24+
procedure TRunWithDocker.Execute(AProject: IOTAProject);
2525
var
26-
LLine, LContainerVersion, LContainerName: string;
2726
LReturn: TRunnerReturn;
28-
LPAServerPort: Integer;
29-
LHasPAServerPort: Boolean;
30-
LPorts: TArray<string>;
27+
LMainMenu: TMainMenu;
28+
LMenuItem: TMenuItem;
3129
begin
30+
ProjectGroup.ActiveProject := AProject;
31+
3232
if not(ActiveProject.CurrentPlatform = 'Linux64') then
3333
raise Exception.Create('Plataform not suported');
3434

35-
LContainerVersion := TVersion.GetInstance.Semantic + '-' + TVersion.GetInstance.Name;
36-
LContainerName := ExtractFileName(ActiveProject.FileName).Split(['.'])[0] + '_' + LContainerVersion;
37-
38-
LReturn := Runner('docker start ' + LContainerName);
39-
40-
if LReturn.ExitCode = COMMAND_ERROR then
41-
LReturn := Runner('docker run -tP --name ' + LContainerName + ' hashload/delphi-dev:' +
42-
LContainerVersion);
35+
LReturn := Runner('docker-compose up -d');
4336

4437
if LReturn.ExitCode = COMMAND_SUCESS then
4538
begin
46-
LReturn := Runner('docker ps --filter name=teste_10.3.0-rio --format "{{.Ports}}"');
47-
48-
LPorts := LReturn.Output.Split([',']);
49-
for LLine in LPorts do
50-
begin
51-
LHasPAServerPort := False;
52-
if LLine.Contains('->64211/tcp') then
53-
begin
54-
LPAServerPort := LLine.Substring(LLine.IndexOf(':') + 1, LLine.IndexOf('->') - LLine.IndexOf(':') - 1)
55-
.ToInteger;
56-
LHasPAServerPort := True;
57-
Break;
58-
end;
59-
end;
39+
LMainMenu := NativeServices.MainMenu;
6040

61-
if not LHasPAServerPort then
62-
raise Exception.Create('PAServer not found');
63-
end;
64-
65-
if LReturn.ExitCode = COMMAND_ERROR then
41+
LMenuItem := LMainMenu.Items.Find('Run').Find('Run');
42+
if Assigned(LMenuItem) then
43+
LMenuItem.Action.Execute;
44+
end
45+
else
6646
raise Exception.Create(LReturn.Output);
67-
68-
ShowMessage('Version ' + TVersion.GetInstance.Semantic);
6947
end;
7048

7149
end.

Src/Docker/Docker.Utils.pas

Lines changed: 0 additions & 46 deletions
This file was deleted.

Src/OpenToolApi/OpenToolApi.CommandMessage.pas

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ procedure TCommandMessage.Initialize(AService: IOTAMessageServices);
4646

4747
FGroup.AutoScroll := True;
4848
FGroup.CanClose := False;
49-
FService.AddTitleMessage('Docker initialized..', FGroup);
5049
end;
5150

5251
procedure TCommandMessage.WriteLn(ALine: string);

0 commit comments

Comments
 (0)