Skip to content

Commit afccae6

Browse files
committed
Merge branch 'develop' into 3.4-dev-dockersupport
2 parents 4d61b46 + 702c1d1 commit afccae6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+2329
-593
lines changed

docs-src/commands.md

Lines changed: 94 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ namespace MyCommandPlugin
4444
}
4545
```
4646

47-
Extending the **InEngine.Core.AbstractCommand** class adds extra functionality, like a logger, a progress bar, and the ability to schedule the command using the scheduler.
47+
A command that implements ICommand can be run directly or [queued](queuing), but it cannot be [scheduled](scheduling).
48+
Extending the **InEngine.Core.AbstractCommand** class adds extra functionality, like a progress bar, and the ability to schedule the command using the scheduler.
4849
Minimally, the Run method should be overridden.
4950

5051
```c#
@@ -63,12 +64,12 @@ namespace MyCommandPlugin
6364
}
6465
```
6566

66-
6767
## Run a Command
6868

6969
Create a class that implements **InEngine.Core.IOptions** in the same assembly as the command class.
70-
Add a VerbOptions attribute from the CommandLine namespace that defines the name of the command and optional help text.
71-
The help text can be auto-generated from the attribute or manually specified in the GetUsage method.
70+
Add a VerbOptions attribute, from the CommandLine namespace, that defines the name of the command.
71+
Optional help text can also be specified in the VerbOption attribute.
72+
The help text can be auto-generated from the attribute or manually specified in the GetUsage method if desired.
7273

7374
```c#
7475
using CommandLine;
@@ -93,20 +94,30 @@ namespace MyCommandPlugin
9394

9495
Download the InEngine binary distribution, from the [GitHub Releases](https://github.com/InEngine-NET/InEngine.NET/releases) page, that matches the version of the InEngine.Core package you included.
9596

96-
Copy your project's DLLs into the same directory as inengine.exe.
97+
Copy your project's DLLs into the Plugins subdirectory included in the binary distribution.
98+
Add your plugin to the ["Plugins" list in appsettings.config](configuration) at the root of the binary distribution.
9799

98-
Run your command...
100+
Run your command:
99101

100102
```bash
101103
inengine.exe -pMyCommandPlugin my-command
102104
```
103105

104-
## Discover Command Plugins
106+
### Executing Arbitrary Processes
105107

106-
Run inengine.exe without any arguments to see a list of plugins.
108+
It isn't necessary to create C# classes to utilize InEngine.NET.
109+
Arbitrary commands can be run, with an argument list by leveraging the InEngine.Core plugin's **proc** command.
110+
The command lists directory contents using "ls" with the "-lhp" switches:
107111

108-
```text
112+
```bash
113+
inengine.exe -pInEngine.Core proc -c"/bin/ls" -a"-lhp"
114+
```
109115

116+
## View Available Plugins
117+
118+
Run inengine.exe without any arguments to see a list of plugins:
119+
120+
```text
110121
___ _____ _ _ _ _____ _____
111122
|_ _|_ __ | ____|_ __ __ _(_)_ __ ___ | \ | | ____|_ _|
112123
| || '_ \| _| | '_ \ / _` | | '_ \ / _ \ | \| | _| | |
@@ -115,137 +126,158 @@ Run inengine.exe without any arguments to see a list of plugins.
115126
|___/
116127
117128
Usage:
118-
-p[<plugin_name>] [<command_name>]
129+
InEngine 3.x
130+
Copyright © 2017 Ethan Hann
131+
132+
p, plugin Plug-In to activate.
133+
134+
s, scheduler Run the scheduler.
135+
136+
c, configuration (Default: ./appsettings.json) The path to the
137+
configuration file.
138+
119139
120140
Plugins:
121-
InEngine.Commands
122141
InEngine.Core
123-
124142
```
125143

126-
## Discover Commands in a Plugin
144+
## View Commands in a Plugin
127145

128-
Run inengine.exe with only the plugin specified.
146+
Run inengine.exe with only the plugin specified:
129147

130148
```bash
131149
inengine.exe -pInEngine.Core
132150
```
133151

134-
The **InEngine.Core** library is itself a plugin that contains queue related commands.
152+
The **InEngine.Core** library is itself a plugin that contains queue-related and other commands.
135153
As an example, this is the help output for the core plugin.
136154

137155
```text
138-
139156
___ _____ _ _ _ _____ _____
140157
|_ _|_ __ | ____|_ __ __ _(_)_ __ ___ | \ | | ____|_ _|
141158
| || '_ \| _| | '_ \ / _` | | '_ \ / _ \ | \| | _| | |
142159
| || | | | |___| | | | (_| | | | | | __/_| |\ | |___ | |
143160
|___|_| |_|_____|_| |_|\__, |_|_| |_|\___(_|_| \_|_____| |_|
144161
|___/
145162
146-
Plugin: InEngine.Core
163+
Plugin:
164+
Name: InEngine.Core
165+
Version: 3.x
166+
147167
148168
Commands:
149-
null A null operation command. Literally does nothing.
150-
echo Echo some text to the console. Useful for end-to-end testing.
151-
queue:publish Publish a command message to a queue.
152-
queue:consume Consume one or more command messages from the queue.
153-
queue:length Get the number of messages in the primary and secondary queues.
154-
queue:clear Clear the primary and secondary queues.
169+
queue:publish Publish a command message to a queue.
170+
queue:consume Consume one or more command messages from the queue.
171+
queue:length Get the number of messages in the primary and secondary queues.
172+
queue:flush Clear the primary or secondary queues.
173+
queue:republish Republish failed messages to the queue.
174+
queue:peek Peek at messages in the primary or secondary queues.
175+
echo Echo some text to the console. Useful for end-to-end testing.
176+
proc Launch an arbitrary process.
155177
```
156178

157179
## Print Help Text for a Plugin's Commands
158180

159181
Run the command with the -h or --help arguments.
160182

161183
```bash
162-
inengine.exe -pInEngine.Core queue:clear -h
184+
inengine.exe -pInEngine.Core queue:publish -h
163185
```
164186

165187
The **InEngine.Core** plugin's command to clear the InEngine.NET queues produces this help message.
166188

167189
```text
168190
InEngine 3.x
169-
Copyright © Ethan Hann 2017
191+
Copyright © 2017 Ethan Hann
170192
171-
--processing-queue Clear the processing queue.
193+
--command-plugin Required. The name of a command plugin file, e.g.
194+
InEngine.Core.dll
172195
173-
--secondary Clear the secondary queue.
174-
```
196+
--command-verb A plugin command verb, e.g. echo
175197
176-
## Writing Output
198+
--command-class A command class name, e.g.
199+
InEngine.Core.Commands.AlwaysSucceed. Takes precedence
200+
over --command-verb if both are specified.
177201
178-
The **InEngine.Core.AbstractCommand** class provides some helper functions to output text to the console:
202+
--args An optional list of arguments to publish with the
203+
command.
179204
180-
```c#
181-
IWrite Newline();
182-
IWrite Info(string val);
183-
IWrite Warning(string val);
184-
IWrite Error(string val);
185-
IWrite Line(string val);
205+
--secondary (Default: False) Publish the command to the secondary
206+
queue.
186207
```
187208

209+
## Writing Output
210+
211+
The **InEngine.Core.AbstractCommand** class provides some helper functions to output text to the console, for example:
212+
188213
```c#
189214
public override void Run()
190215
{
191-
Info("Display some information");
216+
Line("Display some information");
192217
}
193218
```
194219

195-
Display an error message, use the Error method.
220+
All of these commands append a newline to the end of the specified text:
196221

197222
```c#
198-
Error("Display some information");
223+
Line("This is some text"); // Text color is white
224+
Info("Something good happened"); // Text color is green
225+
Warning("Something not so good happened"); // Text color is yellow
226+
Error("Something bad happened"); // Text color is red
199227
```
200228

201-
Display a warning message, use the Warning method.
229+
These commands are similar, but they do not append a newline:
202230

203231
```c#
204-
Error("Display some information");
232+
Text("This is some text"); // Text color is white
233+
InfoText("Something good happened"); // Text color is green
234+
WarningText("Something not so good happened"); // Text color is yellow
235+
ErrorText("Something bad happened"); // Text color is red
205236
```
206237

207-
Info, Error, and Warning messages are display in green, red, and yellow, respectively.
208-
If you want to display an uncolored line, use the Line method.
209-
Line("This is a plain line.");
210-
211-
## Logging
238+
You can also display newlines:
239+
240+
```c#
241+
Newline(); // 1 newline
242+
Newline(5); // 5 newlines
243+
Newline(10); // 10 newlines
244+
```
212245

213-
The **InEngine.Core.AbstractCommand** class provides a Logger property. It implements the **NLog.ILogger** interface.
246+
The methods can be chained together:
214247

215248
```c#
216-
public override void Run()
217-
{
218-
Logger.Trace("Sample trace message");
219-
Logger.Debug("Sample debug message");
220-
Logger.Info("Sample informational message");
221-
Logger.Warn("Sample warning message");
222-
Logger.Error("Sample error message");
223-
Logger.Fatal("Sample fatal error message");
224-
}
249+
InfoText("You have this many things: ")
250+
.Line("23")
251+
.NewLine(2)
252+
.InfoText("You have this many other things: ")
253+
.Line("34")
254+
.NewLine(2);
225255
```
226256

227-
Setup an [NLog configuration](https://github.com/NLog/NLog/wiki/Tutorial#configuration) file, something like this...
257+
## Logging
258+
259+
Any exceptions thrown by a command will be logged provided NLog is configured to record errors.
260+
The [NLog configuration](https://github.com/NLog/NLog/wiki/Tutorial#configuration) file needs to be setup with something like this:
228261

229262
```xml
230263
<?xml version="1.0" encoding="utf-8" ?>
231264
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
232265
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
233266

234267
<targets>
235-
<target name="logfile" xsi:type="File" fileName="file.txt" />
236-
<target name="console" xsi:type="Console" />
268+
<target name="logfile" xsi:type="File" fileName="inengine.log" />
237269
</targets>
238270

239271
<rules>
240-
<logger name="*" minlevel="Trace" writeTo="logfile" />
241-
<logger name="*" minlevel="Info" writeTo="console" />
272+
<logger name="*" minlevel="Error" writeTo="logfile" />
242273
</rules>
243274
</nlog>
244275
```
245276

246277
## Progress Bar
247278

248-
The **InEngine.Core.AbstractCommand** class provides a ProgressBar property. This is how it is used.
279+
The **InEngine.Core.AbstractCommand** class provides a ProgressBar property to show command progress in a terminal.
280+
This is how it is used:
249281

250282
```c#
251283
public override void Run()

docs-src/configuration.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ Configuration is accomplished by modifying the appsettings.json file that comes
66
```json
77
{
88
"InEngine": {
9+
"Plugins": [
10+
"path/to/MyCommandPlugin"
11+
],
912
"Queue": {
13+
"UseCompression": false,
1014
"PrimaryQueueConsumers": 16,
1115
"SecondaryQueueConsumers": 4,
1216
"QueueName": "InEngine:Queue",
@@ -20,15 +24,23 @@ Configuration is accomplished by modifying the appsettings.json file that comes
2024

2125
```
2226

23-
| Setting | Description |
24-
| ------------------------- | ------------------------- |
25-
| PrimaryQueueConsumers | The number of consumers to schedule for the primary queue. |
26-
| SecondaryQueueConsumers | The number of consumers to schedule for the secondary queue. |
27-
| QueueName | The base name of the queue, used to form the Redis Queue keys. |
28-
| RedisHost | The Redis hostname to connect to. |
29-
| RedisPort | Redis's port. |
30-
| RedisDb | The Redis database - 0-15 |
31-
| RedisPassword | The Redis auth password |
3227

28+
## Top-level Settings
3329

30+
| Setting | Type | Description |
31+
| ------------------------- | ----------------- | --------------------------------------------------------------------------------- |
32+
| Plugins | array of strings | A list of paths of plugin assemblies, with ".dll" omitted from the assembly name. |
3433

34+
35+
## Queue Settings
36+
37+
| Setting | Type | Description |
38+
| ------------------------- | --------- | --------------------------------------------------------------------- |
39+
| UseCompression | bool | A situation performance optimization that compresses queued messages. |
40+
| PrimaryQueueConsumers | string | The number of consumers to schedule for the secondary queue. |
41+
| SecondaryQueueConsumers | string | The number of consumers to schedule for the secondary queue. |
42+
| QueueName | string | The base name of the queue, used to form the Redis Queue keys. |
43+
| RedisHost | string | The Redis hostname to connect to. |
44+
| RedisPort | integer | Redis's port. |
45+
| RedisDb | integer | The Redis database - 0-15 |
46+
| RedisPassword | string | The Redis auth password |

0 commit comments

Comments
 (0)