Default Command

The default command executes when no command name is passed. It provides three built-in options, which are mutually exclusive:

OptionFlagsBehavior
help-h | -? | --helpRenders help output.
version-v | --versionRenders assembly version information.
run-r | --runStarts an interactive command loop.

Help

Help is global rather than per-command: you pass the target command or namespace name as the argument to the default command’s --help option — you do not pass --help to the command itself.

Without an argument, renders baseline help — usage patterns and default options. An optional argument scopes the output to a command or namespace. A namespace argument accepts a wildcard (*). The wildcard will render a list of all descendent namespaces and commands:

myapp --help                        # baseline help
myapp --help netsh                  # namespace help
myapp --help netsh.wlan.connect     # command help
myapp --help netsh.*                # all commands under a namespace

Help output is template-rendered using embedded resources. The Help function extracts namespace and command definition metadata in order to render consistent help content. Command options can be excluded from help content by calling the OptionDefinition.Hide() method.

Version

Reflects over the entry assembly and its referenced assemblies, excluding system assemblies. Each name is printed with its Major.Minor.Build version:

myapp --version
MyApp......................1.0.0
HatTrick.CommandLine.......2.4.1
HatTrick.Text.Templating...2.2.0
HatTrick.MemDb.............6.1.0

Run

Starts a continuous command execution loop — the application accepts repeated commands without exiting:

myapp --run
myapp> netsh.wlan.connect --name MyNetwork
Connection request was completed successfully.
myapp> netsh.wlan.disconnect
Disconnection request was completed successfully for interface "Wi-Fi".
myapp> cls
myapp> exit

Three built-in loop commands are reserved: exit and bye terminate the loop; cls clears the screen.