Skip to content

Commit 50ba1ce

Browse files
committed
Allow command help text to be printed. Update docs
1 parent 74e0b6b commit 50ba1ce

File tree

12 files changed

+511
-190
lines changed

12 files changed

+511
-190
lines changed

docs-src/commands.md

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
# Commands
2+
3+
Commands are the fundamental abstraction used to run custom logic.
4+
5+
## Create a Command
6+
7+
The InEngine.Core package is required. Install it into your own Visual Studio project.
8+
9+
**Package Manager**
10+
```bash
11+
Install-Package InEngine.Core
12+
```
13+
14+
**Nuget CLI**
15+
```bash
16+
nuget install InEgine.Core
17+
```
18+
19+
**.NET CLI**
20+
```bash
21+
dotnet add package InEngine.Core
22+
```
23+
24+
**Paket CLI**
25+
```bash
26+
paket add InEngine.Core
27+
```
28+
29+
Adding a class that implements **InEngine.Core.ICommand** is the simplest way to create a command.
30+
31+
```csharp
32+
using System;
33+
using InEngine.Core;
34+
35+
namespace MyCommandPlugin
36+
{
37+
public class MyCommand : ICommand
38+
{
39+
public CommandResult Run()
40+
{
41+
Console.WriteLine("Hello, world!");
42+
return new CommandResult(true);
43+
}
44+
}
45+
}
46+
```
47+
48+
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.
49+
Minimally, the Run method should be overridden.
50+
51+
```csharp
52+
using System;
53+
using InEngine.Core;
54+
55+
namespace MyCommandPlugin
56+
{
57+
public class MyCommand : ICommand
58+
{
59+
public override CommandResult Run()
60+
{
61+
Console.WriteLine("Hello, world!");
62+
return new CommandResult(true);
63+
}
64+
}
65+
}
66+
```
67+
68+
## Run a Command
69+
70+
Create a class that implements **InEngine.Core.IOptions** in the same assembly as the command class.
71+
Add a VerbOptions attribute from the CommandLine namespace that defines the name of the command and optional help text.
72+
The help text can be auto-generated from the attribute or manually specified in the GetUsage method.
73+
74+
```csharp
75+
using CommandLine;
76+
using CommandLine.Text;
77+
using InEngine.Core;
78+
79+
namespace MyCommandPlugin
80+
{
81+
public class MyOptions : IOptions
82+
{
83+
[VerbOption("my-command", HelpText="My example command.")]
84+
public MyCommand MyCommand { get; set; }
85+
86+
[HelpVerbOption]
87+
public string GetUsage(string verb)
88+
{
89+
return HelpText.AutoBuild(this, verb);
90+
}
91+
}
92+
}
93+
```
94+
95+
Download the InEngineCli tool that matches the version of the InEngine.Core package you included from the [GitHub Releases](https://github.com/InEngine-NET/InEngine.NET/releases) page.
96+
97+
Copy your project's DLLs into the same directory as InEngineCli.exe.
98+
99+
Run your command...
100+
101+
```bash
102+
InEngineCli.exe -pMyCommandPlugin my-command
103+
```
104+
105+
## Discover Commands Plugins
106+
107+
Run InEngineCli.exe without any arguments to see a list of arguments.
108+
109+
```
110+
Available plugins...
111+
InEngine.Commands
112+
InEngine.Core
113+
```
114+
115+
## Discover Commands in a Plugin
116+
117+
Run InEngineCli.exe with only the plugin specified.
118+
119+
```
120+
InEngineCli.exe -pInEngine.Core
121+
```
122+
123+
The **InEngine.Core** library is itself a plugin that contains queue related commands.
124+
This is the help output for the core plugin.
125+
126+
```
127+
InEngine 3.1.0
128+
Copyright © Ethan Hann 2017
129+
130+
queue:publish Publish a command message to a queue.
131+
132+
queue:consume Consume one or more command messages from the queue.
133+
134+
queue:length Get the number of messages in the primary and secondary
135+
queues.
136+
137+
queue:clear Clear the primary and secondary queues.
138+
```
139+
140+
## Print Help Text for a Plugin's Commands
141+
142+
Run the command with the -h or --help arguments.
143+
144+
```
145+
InEngineCli.exe -pInEngine.Core queue:clear -h
146+
```
147+
148+
The **InEngine.Core** plugin's command to clear the InEngine.NET's queues produces this help message.
149+
150+
```
151+
InEngine 3.1.0
152+
Copyright © Ethan Hann 2017
153+
154+
--processing-queue Clear the processing queue.
155+
156+
--secondary Clear the secondary queue.
157+
```
158+

docs-src/index.md

Lines changed: 1 addition & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -5,93 +5,4 @@ It allows commands to be queued, scheduled, and ran directly.
55

66
## How to Get Started
77

8-
### Create a Command
9-
10-
First, install the InEngine.Core package into your own Visual Studio project.
11-
12-
**Package Manager**
13-
```bash
14-
Install-Package InEngine.Core
15-
```
16-
17-
**Nuget CLI**
18-
```bash
19-
nuget install InEgine.Core
20-
```
21-
22-
**.NET CLI**
23-
```bash
24-
dotnet add package InEngine.Core
25-
```
26-
27-
**Paket CLI**
28-
```bash
29-
paket add InEngine.Core
30-
```
31-
32-
Add a class that implements **InEngine.Core.ICommand** or extends **InEngine.Core.AbstractCommand**.
33-
The **AbstractCommand** class adds extra functionality, like a logger, a progress bar, and the ability to schedule the command using the scheduler.
34-
Minimally, the Run method should be overridden.
35-
36-
```csharp
37-
using System;
38-
using InEngine.Core;
39-
40-
namespace MyCommands
41-
{
42-
public class MyCommand : ICommand
43-
{
44-
public CommandResult Run()
45-
{
46-
Console.WriteLine("Hello, world!");
47-
return new CommandResult(true);
48-
}
49-
}
50-
}
51-
```
52-
53-
Create a class that implements **InEngine.Core.IOptions** in the same assembly as the command class.
54-
Add VerbOptions from the CommandLine namespace.
55-
The help text can be auto-generated or manually specified.
56-
57-
```csharp
58-
using CommandLine;
59-
using CommandLine.Text;
60-
using InEngine.Core;
61-
62-
namespace InEngine.Commands
63-
{
64-
public class MyOptions : IOptions
65-
{
66-
[VerbOption("my-command", HelpText="My example command.")]
67-
public MyCommand MyCommand { get; set; }
68-
69-
[HelpVerbOption]
70-
public string GetUsage(string verb)
71-
{
72-
return HelpText.AutoBuild(this, verb);
73-
}
74-
}
75-
}
76-
```
77-
78-
### Run the Command
79-
80-
Second, download the InEngineCli tool that matches the version of the InEngine.Core package you included from the [GitHub Releases](https://github.com/InEngine-NET/InEngine.NET/releases) page.
81-
82-
Copy your project's DLLs into the same directory as InEngineCli.exe.
83-
84-
Run your command...
85-
86-
```bash
87-
InEngineCli.exe -pMyCommands my-command
88-
```
89-
90-
91-
92-
93-
94-
95-
96-
97-
8+
Get started by reading up on [commands](commands).

docs/404.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@
4444

4545
<!-- Expanded navigation -->
4646
<div class="navbar-collapse collapse">
47+
<!-- Main navigation -->
48+
<ul class="nav navbar-nav">
49+
<li >
50+
<a href="/">Getting Started</a>
51+
</li>
52+
<li >
53+
<a href="/commands/">Commands</a>
54+
</li>
55+
</ul>
4756

4857
<ul class="nav navbar-nav navbar-right">
4958
<li>

0 commit comments

Comments
 (0)