Skip to content

Configuring commands

JFBlouin edited this page Apr 10, 2019 · 7 revisions

A command represents an executable unit of work that can be executed by your tool. Defining at least one method with the [Command] attribute is the only required modification you need to do in your code in order for it to be executable on the command line.


The Command attribute

Any method which is meant to be executable, i.e. a command, should be decorated with the Command attribute, located in the CommandLineEngine.Attributes namespace. This attribute accepts the following values, all of which are optional:

Property Use
Name Allows you to override the name of the command, by default, uses the method name.
Description Allows you to specify a description for the method, will be shown in help.
HelpUrl Allows you to specify a URL for more information, will be shown in help.

A command will be executable using MyApp.exe commandName


Static methods

The methods defined as commands should be static. When executing the command, the engine will simply invoke the method.

Note that it is possible to execute a non static method, however, the method must be located in a class having a public non-empty constructor. The engine will try to instantiate the containing class, but will fail if it does not find one.