CommandParser

A type that can parse an argument list into a command.

Description: One may wonder, "what's the difference between CommandParser and CommandLineInterface?".

The answer is simple: CommandParser only performs argument parsing and value binding for a single command, whereas CommandLineInterface builds on top of CommandParser and several other components in order to support multiple commands via a complete CLI interface.

So in short, if all you want from JCLI is its command modeling and parsing abilties without all the extra faff provided by CommandLineInterface, and you're fine with performing execution by yourself, then you'll want to use this type.

More...

Members

Functions

parse
Result!void parse(ArgPullParser parser, CommandT commandInstance)

Parses the given arguments into your command instance.

parse
Result!void parse(string[] args, CommandT commandInstance)

Same as parse except it will automatically construct an ArgPullParser for you.

Manifest constants

Info
enum Info;

The CommandInfo for the command being parsed. Special note is that this is compile-time viewable.

Parameters

CommandT

The type of your command.

ArgBinderInstance

The ArgBinder to use when binding arguments to the user provided values.

Detailed Description

Commands

Commands and arguments are defined in the same way as CommandLineInterface documents.

However, you don't need to define an onExecute function as this type has no concept of executing commands, only parsing them.

Dependency Injection

This is a feature provided by CommandLineInterface, not CommandParser.

Command instances must be constructed outside of CommandParser, as it has no knowledge on how to do this, it only knows how to parse data into it.

Meta