Skip to content

Commit 320fe61

Browse files
committed
Initial call to docker wrapper
1 parent 96b3f2e commit 320fe61

15 files changed

+1371
-28
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
__history/
6262
__recovery/
6363
*.~*
64+
modules/
6465

6566
# Castalia statistics file (since XE7 Castalia is distributed with Delphi)
6667
*.stat

DelphiDocker.dpk

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,20 @@ package DelphiDocker;
3030

3131
requires
3232
rtl,
33-
designide;
33+
designide,
34+
boss_ide;
3435

3536
contains
36-
OpenToolApi.LocalMenuItem in 'Src\OpenToolApi\OpenToolApi.LocalMenuItem.pas',
3737
OpenToolApi.Register in 'Src\OpenToolApi\OpenToolApi.Register.pas',
3838
OpenToolApi.ToolBarItem in 'Src\OpenToolApi\OpenToolApi.ToolBarItem.pas' {ToolBarItem: TDataModule},
3939
Command.Runner in 'Src\Command\Command.Runner.pas',
40-
OpenToolApi.CommandMessage in 'Src\OpenToolApi\OpenToolApi.CommandMessage.pas';
40+
OpenToolApi.CommandMessage in 'Src\OpenToolApi\OpenToolApi.CommandMessage.pas',
41+
OpenToolApi.LocalMenuItem in 'Src\OpenToolApi\OpenToolApi.LocalMenuItem.pas',
42+
OpenToolApi.Events in 'Src\OpenToolApi\OpenToolApi.Events.pas',
43+
UtilityFunctions in 'Src\OpenToolApi\UtilityFunctions.pas',
44+
Wrapper.Docker in 'Src\wrapper\Wrapper.Docker.pas',
45+
Wrapper.DockerCompose in 'Src\wrapper\Wrapper.DockerCompose.pas',
46+
Command.Cmd in 'Src\Command\Command.Cmd.pas',
47+
Command.Message in 'Src\Command\Command.Message.pas';
4148

4249
end.

DelphiDocker.dproj

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<ProjectGuid>{CC69F17C-E429-4154-899A-E9F0ACA9841F}</ProjectGuid>
44
<MainSource>DelphiDocker.dpk</MainSource>
5-
<ProjectVersion>18.5</ProjectVersion>
5+
<ProjectVersion>18.6</ProjectVersion>
66
<FrameworkType>VCL</FrameworkType>
77
<Base>True</Base>
88
<Config Condition="'$(Config)'==''">Debug</Config>
@@ -67,7 +67,7 @@
6767
<VerInfo_Locale>1046</VerInfo_Locale>
6868
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
6969
<DCC_BplOutput>.\$(Platform)\$(Config)</DCC_BplOutput>
70-
<DCC_UnitSearchPath>modules\DOSCommand\Source;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
70+
<DCC_UnitSearchPath>$(DCC_UnitSearchPath);$(DCC_UnitSearchPath);modules\DOSCommand\Source;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
7171
</PropertyGroup>
7272
<PropertyGroup Condition="'$(Base_Linux64)'!=''">
7373
<DCC_UsePackage>rtl;$(DCC_UsePackage)</DCC_UsePackage>
@@ -95,7 +95,7 @@
9595
<DCC_RemoteDebug>false</DCC_RemoteDebug>
9696
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
9797
<VerInfo_Locale>1033</VerInfo_Locale>
98-
<Debugger_HostApplication>C:\Program Files (x86)\Embarcadero\Studio\20.0\bin\bds.exe</Debugger_HostApplication>
98+
<Debugger_HostApplication>E:\tools\Embarcadero\Studio\20.0\bin\bds.exe</Debugger_HostApplication>
9999
</PropertyGroup>
100100
<PropertyGroup Condition="'$(Cfg_2)'!=''">
101101
<DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
@@ -113,7 +113,7 @@
113113
</DelphiCompile>
114114
<DCCReference Include="rtl.dcp"/>
115115
<DCCReference Include="designide.dcp"/>
116-
<DCCReference Include="Src\OpenToolApi\OpenToolApi.LocalMenuItem.pas"/>
116+
<DCCReference Include="boss_ide.dcp"/>
117117
<DCCReference Include="Src\OpenToolApi\OpenToolApi.Register.pas"/>
118118
<DCCReference Include="Src\OpenToolApi\OpenToolApi.ToolBarItem.pas">
119119
<Form>ToolBarItem</Form>
@@ -122,6 +122,13 @@
122122
</DCCReference>
123123
<DCCReference Include="Src\Command\Command.Runner.pas"/>
124124
<DCCReference Include="Src\OpenToolApi\OpenToolApi.CommandMessage.pas"/>
125+
<DCCReference Include="Src\OpenToolApi\OpenToolApi.LocalMenuItem.pas"/>
126+
<DCCReference Include="Src\OpenToolApi\OpenToolApi.Events.pas"/>
127+
<DCCReference Include="Src\OpenToolApi\UtilityFunctions.pas"/>
128+
<DCCReference Include="Src\wrapper\Wrapper.Docker.pas"/>
129+
<DCCReference Include="Src\wrapper\Wrapper.DockerCompose.pas"/>
130+
<DCCReference Include="Src\Command\Command.Cmd.pas"/>
131+
<DCCReference Include="Src\Command\Command.Message.pas"/>
125132
<BuildConfiguration Include="Release">
126133
<Key>Cfg_2</Key>
127134
<CfgParent>Base</CfgParent>
@@ -144,6 +151,8 @@
144151
</Source>
145152
<Excluded_Packages>
146153
<Excluded_Packages Name="$(BDSBIN)\DataExplorerDBXPluginEnt260.bpl">DBExpress Enterprise Data Explorer Integration</Excluded_Packages>
154+
<Excluded_Packages Name="$(BDSBIN)\bcboffice2k260.bpl">Embarcadero C++Builder Office 2000 Servers Package</Excluded_Packages>
155+
<Excluded_Packages Name="$(BDSBIN)\bcbofficexp260.bpl">Embarcadero C++Builder Office XP Servers Package</Excluded_Packages>
147156
<Excluded_Packages Name="$(BDSBIN)\dcloffice2k260.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
148157
<Excluded_Packages Name="$(BDSBIN)\dclofficexp260.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
149158
</Excluded_Packages>

Src/Command/Command.Cmd.pas

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
unit Command.Cmd;
2+
3+
interface
4+
5+
uses
6+
DosCommand;
7+
8+
type
9+
TCommandCmd = class
10+
private
11+
class var
12+
FInstance: TCommandCmd;
13+
FDosCommand: TDosCommand;
14+
15+
procedure OnReadLine(ASender: TObject; const ANewLine: string; AOutputType: TOutputType);
16+
17+
constructor Create;
18+
class procedure Release;
19+
public
20+
21+
procedure Run(ACommand, APath: string);
22+
class function GetInstance: TCommandCmd;
23+
destructor Destroy; override;
24+
25+
end;
26+
27+
implementation
28+
29+
uses
30+
OpenToolApi.CommandMessage;
31+
32+
{ TCommandCmd }
33+
34+
constructor TCommandCmd.Create;
35+
begin
36+
FDosCommand := TDosCommand.Create(nil);
37+
FDosCommand.OnNewLine := OnReadLine;
38+
end;
39+
40+
destructor TCommandCmd.Destroy;
41+
begin
42+
FDosCommand.Stop;
43+
inherited;
44+
end;
45+
46+
class function TCommandCmd.GetInstance: TCommandCmd;
47+
begin
48+
if not Assigned(FInstance) then
49+
FInstance := TCommandCmd.Create;
50+
51+
result := FInstance;
52+
end;
53+
54+
procedure TCommandCmd.OnReadLine(ASender: TObject; const ANewLine: string; AOutputType: TOutputType);
55+
begin
56+
TCommandMessage.GetInstance.WriteLn(ANewLine);
57+
end;
58+
59+
class procedure TCommandCmd.Release;
60+
begin
61+
if Assigned(FInstance) then
62+
FInstance.Free;
63+
end;
64+
65+
procedure TCommandCmd.Run(ACommand, APath: string);
66+
begin
67+
FDosCommand.Stop;
68+
FDosCommand.CommandLine := ACommand;
69+
FDosCommand.CurrentDir := APath;
70+
FDosCommand.Execute;
71+
end;
72+
73+
initialization
74+
75+
finalization
76+
77+
TCommandCmd.Release;
78+
79+
end.

Src/Command/Command.Message.pas

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
unit Providers.Message;
1+
unit Command.Message;
22

33
interface
44

@@ -32,7 +32,7 @@ class procedure TCommandMessage.Release;
3232
FInstance.Free;
3333
end;
3434

35-
class function TProviderMessage.TCommandMessage: TCommandMessage;
35+
class function TCommandMessage.GetInstance: TCommandMessage;
3636
begin
3737
if not Assigned(FInstance) then
3838
FInstance := TCommandMessage.Create;

Src/Command/Command.Runner.pas

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,47 @@ interface
55
uses
66
DOSCommand, OpenToolApi.CommandMessage;
77

8-
procedure Runner(ACommand, APath: string; ALoadPackages: Boolean);
8+
function Runner(ACommand, APath: string): Cardinal;
99

1010
implementation
1111

1212
uses
13-
System.SysUtils;
13+
System.SysUtils, Vcl.Forms;
1414

15-
procedure Runner(ACommand, APath: string; ALoadPackages: Boolean);
15+
function Runner(ACommand, APath: string): Cardinal;
1616
var
1717
LDosCommand: TDosCommand;
1818
begin
1919
LDosCommand := TDosCommand.Create(nil);
2020
try
2121
LDosCommand.OnNewLine := procedure(ASender: TObject; const ANewLine: string; AOutputType: TOutputType)
2222
begin
23-
TCommandMessage.GetInstance.WriteLn(ANewLine);
23+
// TCommandMessage.GetInstance.WriteLn(ANewLine);
24+
end;
25+
26+
LDosCommand.OnTerminated := procedure(ASender: TObject)
27+
begin
28+
// ASender.Free;
2429
end;
2530

2631
LDosCommand.InputToOutput := False;
2732
LDosCommand.CurrentDir := APath;
28-
LDosCommand.CommandLine := GetEnvironmentVariable('COMSPEC');
33+
LDosCommand.CommandLine := ACommand;
2934
LDosCommand.Execute;
30-
LDosCommand.SendLine(ACommand, False);
31-
LDosCommand.SendLine(#13, False);
32-
LDosCommand.SendLine('', True);
33-
finally
3435

36+
while LDosCommand.IsRunning do
37+
begin
38+
Application.ProcessMessages;
39+
Sleep(0);
40+
end;
41+
42+
Result := LDosCommand.ExitCode
43+
44+
finally
45+
LDosCommand.Free;
3546
end;
3647
end;
3748

49+
50+
3851
end.

Src/Docker/Cmd.pas

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
unit Cmd;
2+
3+
interface
4+
5+
type
6+
TDockerProject = class
7+
8+
9+
end;
10+
11+
implementation
12+
13+
end.

Src/OpenToolApi/OpenToolApi.Events.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface
77

88
type
99

10-
TEventsToolBar = class(TInterfacedObject, INTACustomizeToolbarNotifier, IOTANotifier)
10+
TEventsToolBar = class(TInterfacedObject, INTACustomizeToolbarNotifier)
1111
procedure AfterSave;
1212
procedure BeforeSave;
1313
procedure Destroyed;

Src/OpenToolApi/OpenToolApi.Register.pas

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ procedure Register;
1010

1111
implementation
1212

13+
uses
14+
OpenToolApi.Events, Vcl.ActnList, Vcl.Menus, UtilityFunctions;
15+
1316
procedure AddLocalMenuDocker;
1417
var
1518
LNotifierMenuIndex: Integer;
@@ -21,12 +24,17 @@ procedure AddLocalMenuDocker;
2124
procedure AddToolBarDocker;
2225
var
2326
LServices: INTAServices;
27+
LAction: TAction;
28+
LMenuItem: TMenuItem;
2429
begin
2530
LServices := (BorlandIDEServices as INTAServices);
2631
LServices.MenuBeginUpdate;
2732
try
28-
LServices.NewToolbar('Docker', 'Docker');
29-
LServices.AddToolButton('Docker', 'DockerWithDocker', TToolBarItem.GetInstance.ToolBarItemDocker);
33+
LServices.AddImages(TToolBarItem.GetInstance.ImageListDocker);
34+
35+
UtilityFunctions.CreateMenuItem('RunWithDocker', 'Run With Docker', 'Run', TToolBarItem.GetInstance.teste, nil,
36+
False, True, 'Alt+F9');
37+
3038
finally
3139
LServices.MenuEndUpdate;
3240
end;
@@ -42,9 +50,9 @@ procedure AddCommandMessage;
4250

4351
procedure Register;
4452
begin
45-
// AddLocalMenuDocker;
53+
AddLocalMenuDocker;
4654
AddToolBarDocker;
47-
// AddCommandMessage;
55+
AddCommandMessage;
4856
end;
4957

5058
end.

Src/OpenToolApi/OpenToolApi.ToolBarItem.dfm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,11 @@ object ToolBarItem: TToolBarItem
148148
object ActionListDocker: TActionList
149149
Images = ImageListDocker
150150
OnExecute = ActionListDockerExecute
151+
OnUpdate = ActionListDockerUpdate
151152
Left = 40
152153
Top = 40
153154
object ToolBarItemDocker: TAction
155+
Category = 'Run'
154156
Caption = 'Run With Docker'
155157
ImageIndex = 0
156158
end

0 commit comments

Comments
 (0)