|
103 | 103 | <li><a href="#discover-command-plugins">Discover Command Plugins</a></li> |
104 | 104 | <li><a href="#discover-commands-in-a-plugin">Discover Commands in a Plugin</a></li> |
105 | 105 | <li><a href="#print-help-text-for-a-plugins-commands">Print Help Text for a Plugin's Commands</a></li> |
| 106 | + <li><a href="#writing-output">Writing Output</a></li> |
106 | 107 | <li><a href="#logging">Logging</a></li> |
107 | 108 | <li><a href="#progress-bar">Progress Bar</a></li> |
108 | 109 | </ul> |
@@ -235,26 +236,43 @@ <h2 id="print-help-text-for-a-plugins-commands">Print Help Text for a Plugin's C |
235 | 236 | --secondary Clear the secondary queue. |
236 | 237 | </code></pre> |
237 | 238 |
|
| 239 | +<h2 id="writing-output">Writing Output</h2> |
| 240 | +<p>The <strong>InEngine.Core.AbstractCommand</strong> class provides some helper functions to output text to the console: </p> |
| 241 | +<pre><code class="csharp">IWrite Newline(); |
| 242 | +IWrite Info(string val); |
| 243 | +IWrite Warning(string val); |
| 244 | +IWrite Error(string val); |
| 245 | +IWrite Line(string val); |
| 246 | +</code></pre> |
| 247 | + |
| 248 | +<pre><code class="csharp">public CommandResult Run() |
| 249 | +{ |
| 250 | + Info("Display some information"); |
| 251 | +} |
| 252 | +</code></pre> |
| 253 | + |
| 254 | +<p>Display an error message, use the Error method.</p> |
| 255 | +<pre><code class="csharp">Error("Display some information"); |
| 256 | +</code></pre> |
| 257 | + |
| 258 | +<p>Display a warning message, use the Warning method.</p> |
| 259 | +<pre><code class="csharp">Error("Display some information"); |
| 260 | +</code></pre> |
| 261 | + |
| 262 | +<p>Info, Error, and Warning messages are display in green, red, and yellow, respectively. |
| 263 | +If you want to display an uncolored line, use the Line method. |
| 264 | +Line("This is a plain line.");</p> |
238 | 265 | <h2 id="logging">Logging</h2> |
239 | 266 | <p>The <strong>InEngine.Core.AbstractCommand</strong> class provides a Logger property. It implements the <strong>NLog.ILogger</strong> interface.</p> |
240 | | -<pre><code class="csharp">using System; |
241 | | -using InEngine.Core; |
242 | | - |
243 | | -namespace MyCommandPlugin |
| 267 | +<pre><code class="csharp">public CommandResult Run() |
244 | 268 | { |
245 | | - public class MyCommand : ICommand |
246 | | - { |
247 | | - public override CommandResult Run() |
248 | | - { |
249 | | - Logger.Trace("Sample trace message"); |
250 | | - Logger.Debug("Sample debug message"); |
251 | | - Logger.Info("Sample informational message"); |
252 | | - Logger.Warn("Sample warning message"); |
253 | | - Logger.Error("Sample error message"); |
254 | | - Logger.Fatal("Sample fatal error message"); |
255 | | - return new CommandResult(true); |
256 | | - } |
257 | | - } |
| 269 | + Logger.Trace("Sample trace message"); |
| 270 | + Logger.Debug("Sample debug message"); |
| 271 | + Logger.Info("Sample informational message"); |
| 272 | + Logger.Warn("Sample warning message"); |
| 273 | + Logger.Error("Sample error message"); |
| 274 | + Logger.Fatal("Sample fatal error message"); |
| 275 | + return new CommandResult(true); |
258 | 276 | } |
259 | 277 | </code></pre> |
260 | 278 |
|
|
0 commit comments