Skip to content

Calling the engine in your code

JF Blouin edited this page Apr 10, 2019 · 6 revisions

You can use the two classes in the root CommandLineEngine namespace to interact with your code once configured. In order to execute a command, you need to call the engine from your code.


The CommandExecutor

This class contains a single method, Execute(), whose main propose is to execute.

This method should be called from the Main method, by passing the recieved command line arguments.

Many overloads exists, but the full list of parameters is:

Name Use
string[] args Required. Arguments recieved from command line.
Type[] types Type in which to extract commands. Can be null to scan entire assembly, a single type, or a list of types. Can also be in external assembly.
IHelpFormatter helpFormatter Formatter to use when displaying help. By default, to a console.
Action<Parser.Configuration> configurationBuilder Action to configure the engine.

If you pass null as args, they will be gathered from the Environment class.


The CommandParser

This class contains methods to Parse() the commands and parameters and PrintHelp().

This class should not be called directly, mostly used by CommandExecutor and for debugging purposes.

Clone this wiki locally