You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs-src/commands.md
+27-11Lines changed: 27 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,9 @@ namespace MyCommandPlugin
50
50
## Run a Command
51
51
52
52
Create a class that extends **InEngine.Core.AbstractPlugin** in the same assembly as the command class.
53
-
Add a VerbOptions attribute, from the CommandLine namespace, that defines the name of the command.
53
+
Add a VerbOptions attribute, from the **CommandLine** namespace, that defines the name of the command.
54
+
55
+
This class registers a command in the MyPlugin assembly called "mycommand":
54
56
55
57
```c#
56
58
usingCommandLine;
@@ -61,7 +63,7 @@ namespace MyCommandPlugin
61
63
{
62
64
publicclassMyPlugin : AbstractPlugin
63
65
{
64
-
[VerbOption("my-command", HelpText="My example command.")]
66
+
[VerbOption("mycommand", HelpText="My example command.")]
65
67
publicMyCommandMyCommand { get; set; }
66
68
}
67
69
}
@@ -70,12 +72,12 @@ namespace MyCommandPlugin
70
72
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.
71
73
72
74
Copy your project's DLLs into the Plugins subdirectory included in the binary distribution.
73
-
Add your plugin to the ["Plugins" list in appsettings.config](configuration) at the root of the binary distribution.
75
+
Add your plugin to the "Plugins" list in [appsettings.config](configuration) at the root of the binary distribution.
74
76
75
77
Run your command:
76
78
77
79
```bash
78
-
inengine.exe my-command
80
+
inengine.exe mycommand
79
81
```
80
82
81
83
### Writing Output
@@ -149,29 +151,43 @@ public override void Run()
149
151
150
152
### Running non-.NET Commands
151
153
152
-
It isn't necessary to create C# classes to utilize InEngine.NET.
153
-
Arbitrary commands can be run, with an argument list by leveraging the InEngine.Core plugin's **exec** command.
154
+
It is not necessary to create C# classes to utilize InEngine.NET.
155
+
Arbitrary external programs can be run, with an optional argument list, by leveraging the InEngine.Core plugin's **exec** command.
154
156
155
-
This command prints the version of python:
157
+
For example, create a python script called **helloworld.py**, make it executable, and add this to it:
156
158
157
-
```bash
158
-
inengine.exe exec -e"python" -a"--version"
159
+
```python
160
+
#!/usr/bin/env python
161
+
162
+
print'Hello, world!'
159
163
```
160
164
161
-
Whitelist the "php" command in the [appsettings.json](configuration) file:
165
+
Whitelist the helloworld.py script in the [appsettings.json](configuration) file:
162
166
163
167
```json
164
168
{
165
169
"InEngine": {
166
170
// ...
167
171
"ExecWhitelist": {
168
-
"ls": "ls"
172
+
"helloworld": "/path/to/helloworld.py"
169
173
}
170
174
// ...
171
175
}
172
176
}
173
177
```
174
178
179
+
Now execute it with the **exec** command:
180
+
181
+
```bash
182
+
inengine exec --executable="helloworld"
183
+
```
184
+
185
+
If an external executable requires arguments, use the **--args** argument:
0 commit comments