Command

Command Type

class Command : EventManager {}

Constructors

this
this(string name)
Undocumented in source.

Members

Aliases

Self
alias Self = typeof(this)
Undocumented in source.
exportNAs
alias exportNAs = exportAs!true

export the neagte option flag, see Command.exportAs

findArgument
alias findArgument = _findArgument

get argument by name

findCommand
alias findCommand = _findCommand

get sub command by name

findNOption
alias findNOption = _findNegateOption

get negate option by name, short flag and long flag

findOption
alias findOption = _findOption

get option by name, short flag and long flag

importNAs
alias importNAs = importAs!true

import the neagte option flag, see Command.importAs

Functions

_checkConfilctOption
void _checkConfilctOption()
Undocumented in source. Be warned that the author may not have intended to support it.
_checkMissingMandatoryOption
void _checkMissingMandatoryOption()
Undocumented in source. Be warned that the author may not have intended to support it.
_exit
void _exit(ubyte exitCode)
Undocumented in source. Be warned that the author may not have intended to support it.
_exitErr
void _exitErr(string msg, string code)
Undocumented in source. Be warned that the author may not have intended to support it.
_exitSuccessfully
void _exitSuccessfully()
Undocumented in source. Be warned that the author may not have intended to support it.
_findArgument
inout(Argument) _findArgument(string name)
Undocumented in source. Be warned that the author may not have intended to support it.
_findCommand
inout(Command) _findCommand(string name)
Undocumented in source. Be warned that the author may not have intended to support it.
_findNegateOption
inout(NegateOption) _findNegateOption(string flag)
Undocumented in source. Be warned that the author may not have intended to support it.
_findOption
inout(Option) _findOption(string flag)
Undocumented in source. Be warned that the author may not have intended to support it.
_getCommandAndAncestors
inout(Command)[] _getCommandAndAncestors()
Undocumented in source. Be warned that the author may not have intended to support it.
_getHelpCommand
Command _getHelpCommand()
Undocumented in source. Be warned that the author may not have intended to support it.
_getHelpOption
Option _getHelpOption()
Undocumented in source. Be warned that the author may not have intended to support it.
_helpCommandAction
void _helpCommandAction(OptsWrap _, ArgWrap hcommand)
Undocumented in source. Be warned that the author may not have intended to support it.
_optionImpl
Self _optionImpl(string flags, string desc)
Undocumented in source. Be warned that the author may not have intended to support it.
_optionImpl
Self _optionImpl(string flags, string desc)
Undocumented in source. Be warned that the author may not have intended to support it.
_optionImpl
Self _optionImpl(string flags, string desc, T defaultValue)
Undocumented in source. Be warned that the author may not have intended to support it.
_outputHelpIfRequested
void _outputHelpIfRequested(string[] flags)
Undocumented in source. Be warned that the author may not have intended to support it.
_parseCommand
void _parseCommand(string[] unknowns)
Undocumented in source. Be warned that the author may not have intended to support it.
_prepareUserArgs
string[] _prepareUserArgs(string[] args)
Undocumented in source. Be warned that the author may not have intended to support it.
_processConfigFile
const(JSONValue)*[] _processConfigFile()
Undocumented in source. Be warned that the author may not have intended to support it.
_registerArgument
void _registerArgument(Argument arg)
Undocumented in source. Be warned that the author may not have intended to support it.
_registerCommand
void _registerCommand(Command command)
Undocumented in source. Be warned that the author may not have intended to support it.
_registerOption
void _registerOption(Option option)
Undocumented in source. Be warned that the author may not have intended to support it.
_registerOption
void _registerOption(NegateOption option)
Undocumented in source. Be warned that the author may not have intended to support it.
addActionOption
Self addActionOption(Option option, void delegate(string[] vals...) call_back, bool endMode)

add the action option to command, which will invoke the callback we injected when parsing the flag of this option, only useful in client cmd

addArgument
Self addArgument(Argument argument)

add argument for command

addCommand
Self addCommand(Command cmd, bool[string] cmdOpts)

add the sub command, which is often used when you want more detail configuration of sub command

addHelpCommand
Self addHelpCommand(string flags, string desc)

add the help command

addHelpCommand
Self addHelpCommand(Command cmd)

add the help command

addHelpOption
Self addHelpOption(string flags, string desc)

add the help option

addHelpOption
Self addHelpOption(Option option, void delegate() action)

add the help option

addHelpText
Self addHelpText(AddHelpPos pos, string text)

add a appendent help text at specified position

addOption
Self addOption(Option option)

add the option to command

addOption
Self addOption(NegateOption option)

add the negate option to command

addVersionCommand
Self addVersionCommand(Command cmd)

set version command, see also Self setVersion(string str, string flags = "", string desc = "")

addVersionCommand
Self addVersionCommand(string flags, string desc)

set version command, see also Self setVersion(string str, string flags = "", string desc = "")

addVersionOption
Self addVersionOption(Option opt, void delegate() action)

custom the version option

addVersionOption
Self addVersionOption(string flags, string desc)

set the version option of the command, see also Self setVersion(string str, string flags = "", string desc = "")

aliasName
string aliasName()

get the first alias of command

aliasName
Self aliasName(string aliasStr)

set the alias of command

aliasNames
const(string[]) aliasNames()

get the sequence of aliases of command

aliasNames
Self aliasNames(string[] aliasStrs)

set a sequence of aliases of command

allowExcessArguments
Self allowExcessArguments(bool allow)

whether allow excess argument, default: true

allowExposeOptionValue
Self allowExposeOptionValue(bool allow)

whether allow expose options' values to its sub commands, default: false

allowVariadicMerge
Self allowVariadicMerge(bool allow)

whether allow variadic options' final values merge from different source, default: true

argToOpt
Self argToOpt(string optName, string[] rest)

register an option that can be as the argument of command line. remember that it is positional sensitive and if you want to registered a variadic option, this option must be registered at the end and not other variadic options to be registered

argument
Self argument(string name, string desc, T defaultVal)

define the argument with default value for command, used for variadic argument

argument
Self argument(string name, string desc, T val, T[] rest)

define the argument with default value for command, used for variadic argument

argument
Self argument(string name, string desc, T val)

define the argument with default value for command, used for no-variadic argument

argument
Self argument(string name, string desc)

define the argument for command

argumentDesc
Self argumentDesc(string argName, string desc)

define the arguments' descriptions

argumentDesc
Self argumentDesc(string[string] descMap)

define the arguments' descriptions

arguments
Self arguments(string names)

define manly arguments for command

comineFlagAndOptionValue
Self comineFlagAndOptionValue(bool combine)

whether allow combine flag mode like ls -al, default: true

command
Command command(string nameAndArgs, bool[string] cmdOpts)

define a sub command and sub command's arguments, this sub command inherit the basic configuration of parent command

command
Self command(string name, string desc, string[string] execOpts)

define a sub command, which represents the external command line program

configureHelp
Self configureHelp(Help helpConfig)

configurre the help

configureHelp
inout(Help) configureHelp()

get the help configuration

configureOutput
inout(OutputConfiguration) configureOutput()

get the output cofiguration of command

configureOutput
Self configureOutput(OutputConfiguration config)

configure the output of command

copyInheritedSettings
Self copyInheritedSettings(Command src)

inherit the basic configuration from another command

description
string description()

get the description of command

description
Self description(string str, string[string] argsDesc)

set the description of command

disableHelp
Self disableHelp()

disable the help support

error
void error(string msg, string code)

invoke error when configuring command

excessArguments
void excessArguments()
Undocumented in source. Be warned that the author may not have intended to support it.
execSubCommand
void execSubCommand(string[] unknowns)
Undocumented in source. Be warned that the author may not have intended to support it.
exportAs
Self exportAs(string flag, string[] aliasFlags)

export the option flag as new flag to sub command, so that this new flag can be pased as the the option flag of parent command. this member function aims at avoidind flag conflict between the command and its sub command, after using passThrough on this command. this function would be automatically call Command.passThrough. the flag must be the flag of one of the command's option or negate option. remeber that when parsing the new flag, the option's new flag is prior to the negate option ones. when parsing command line option flags, imported flag is prior to exported one, and the export one is prior to the ordinary pass-through option flag. isNegate decide whether export negate option or non-negate one, default: false

getArgs
ArgWrap[] getArgs()

get the array of arguments' value wrap by ArgWrap. remember use it after parsing or at the action callabck

getOptVal
ArgWrap getOptVal(string key)

get the inner value of a option by name wrapped by ArgWrap. remember better use it in action callabck or after parsing

getOptVal
T getOptVal(string key)

get the inner value in specified type of an option by flags

getOptionValSource
Source getOptionValSource(string key)

get the source of option remember better use it in action callabck or after parsing

getOpts
inout(OptsWrap) getOpts()

get the options' value map wrap by OptsWrap. remember use it after parsing or at the action callabck

getSuggestion
string getSuggestion(string flag)
Undocumented in source. Be warned that the author may not have intended to support it.
getVersion
string getVersion()

get the version string of this command, if not set version, the default is *

help
void help(bool isErrorMode)

invoke the help if the help support is not disabled

helpInfo
string helpInfo(bool isErrorMode)

generate the help info

importAs
Self importAs(string flag, string[] aliasFlags)

import the option flag as new flag from parent command, so that this new flag can be pased as the the option flag of parent command. this member function aims at avoidind flag conflict between the command and its parent command, after using passThrough on parent command. the parent command must exist and parent command must have used passThrough and the flag must be the flag of one of the parent command's option or negate option. remeber that when parsing the new flag, the option's new flag is prior to the negate option ones. when parsing command line option flags, imported flag is prior to exported one, and the export one is prior to the ordinary pass-through option flag. isNegate decide whether import negate option or non-negate one, default: false

injects
Self injects(string name, string[] rest)

inject the options' values exposed by ancestor command by name that are registered using Command.provides or Command.providesAs, so that we can access this option value.

injectsAs
Self injectsAs(string name, string asName)

see also Self injects(string name, string[] rest...). this member function are used for inject an option value as an new name. this is usually used when you want to avoid name confilict.

injectsAs
Self injectsAs(string[string] optsMap)

see also Self injectsAs(in string name, in string asName). inject option values in new names at the same time

name
Self name(string str)

set the name of command

name
string name()

get the name of command

option
Self option(string flags, string desc)

define a value/variadic option to this command

option
Self option(string flags, string desc)

define a bool option to this command

option
Self option(string flags, string desc, T defaultValue)

see also Self option(T)(string flags, string desc) and define a default value for this option

optionMissingArgument
void optionMissingArgument(Option opt)
Undocumented in source. Be warned that the author may not have intended to support it.
outputHelp
void outputHelp(bool isErrorMode)
Undocumented in source. Be warned that the author may not have intended to support it.
parse
void parse(string[] argv)

parse the command line argument variables

parseArguments
void parseArguments(string[] _args)
Undocumented in source. Be warned that the author may not have intended to support it.
parseConfigOptionsImpl
void parseConfigOptionsImpl(const(JSONValue)* config)
Undocumented in source. Be warned that the author may not have intended to support it.
parseOptions
Tuple!(string[], string[]) parseOptions(string[] argv)
Undocumented in source. Be warned that the author may not have intended to support it.
parseOptionsConfig
void parseOptionsConfig()
Undocumented in source. Be warned that the author may not have intended to support it.
parseOptionsEnv
void parseOptionsEnv()
Undocumented in source. Be warned that the author may not have intended to support it.
parseOptionsImply
void parseOptionsImply()
Undocumented in source. Be warned that the author may not have intended to support it.
parsingError
void parsingError(string msg, string code)

invoke error when parsing command line

passThrough
Self passThrough(bool allow)

whether allow pass through options' flags(config, help, version options are not included) behind its sub commands, default: false

provides
Self provides(string name, string[] rest)

expose its option values by names to its sub or sub sub and etc command. its sub or sub sub and etc command can access these option values using Command.injects by names. remember that it is only useful for non-builtin options!

providesAs
Self providesAs(string name, string asName)

see also Self provides(string name, string[] rest...). this member function are used for register an option to be exposed as an new name. this is usually used when you want to avoid name confilict.

providesAs
Self providesAs(string[string] optsMap)

see also Self providesAs(in string name, in string asName). expose option values in new names at the same time

requireOption
Self requireOption(string flags, string desc)

define a mandatory bool option to this command

requiredOption
Self requiredOption(string flags, string desc)

define a mandatory value/variadic option to this command

requiredOption
Self requiredOption(string flags, string desc, T defaultValue)

see also Self requiredOption(T)(string flags, string desc) and define a default value for this option

setConfigOption
Self setConfigOption(string flags, string desc, string defaultDir)

set the config option, if flags not defined, then config option's flags is -C, --config <config-dirs...>; if desc not defined, then description is by default; if defaultDir not defined, then the defaultDir would be ${CURRENT_WORKER_DIR}, which automatically store the path to dir of config file

setHelpCommand
Self setHelpCommand(bool enable)

enable or disable the help command

setHelpCommand
Self setHelpCommand(string flags, string desc)

set the help command

setHelpOption
Self setHelpOption(bool enable)

enable the help option or not

setHelpOption
Self setHelpOption(string flags, string desc)

set the help option

setOptionVal
Self setOptionVal(string key, T value)
Undocumented in source. Be warned that the author may not have intended to support it.
setOptionVal
Self setOptionVal(string key)
Undocumented in source. Be warned that the author may not have intended to support it.
setOptionVal
Self setOptionVal(string key)
Undocumented in source. Be warned that the author may not have intended to support it.
setOptionVal
Self setOptionVal(string key, T value, T[] rest)
Undocumented in source. Be warned that the author may not have intended to support it.
setOptionVal
Self setOptionVal(string key, T[] values)
Undocumented in source. Be warned that the author may not have intended to support it.
setOptionValDirectly
Self setOptionValDirectly(string key, T value, Source src)
Undocumented in source. Be warned that the author may not have intended to support it.
setOptionValDirectly
Self setOptionValDirectly(string key, bool value, Source src)
Undocumented in source. Be warned that the author may not have intended to support it.
setOptionValDirectly
Self setOptionValDirectly(string key, Source src)
Undocumented in source. Be warned that the author may not have intended to support it.
setVersion
Self setVersion(string str, string flags, string desc)

set the version of the command. if flags and desc not defined, then it will automatically set the version option flag -V, --version and version command name version

setVersionCommand
Self setVersionCommand(string flags, string desc)

set version command, see also Self setVersion(string str, string flags = "", string desc = "")

setVersionOption
Self setVersionOption(string flags, string desc)

set the version option of the command, see also Self setVersion(string str, string flags = "", string desc = "")

showGlobalOptions
Self showGlobalOptions(bool enable)

whether show the global options when invoke help, default: false

showHelpAfterError
Self showHelpAfterError(bool displayHelp)

whether show help info when parsing occur error, default: true

showSuggestionAfterError
Self showSuggestionAfterError(bool displaySuggestion)

whether show suggestion info when parsing occur error, default: true

sortOptions
Self sortOptions(bool enable)

whether sort sub options when invoke help, default: false

sortSubCommands
Self sortSubCommands(bool enable)

whether sort sub commands when invoke help, default: false

unknownOption
void unknownOption(string flag)
Undocumented in source. Be warned that the author may not have intended to support it.
usage
string usage()

get the usage of command

usage
Self usage(string str)

set the usage of command

Mixins

__anonymous
mixin SetActionFn!Action

define the action at the end of parsing

Variables

_abandons
Option[] _abandons;
Undocumented in source.
_actionHandler
void delegate() _actionHandler;
Undocumented in source.
_addImplicitHelpCommand
bool _addImplicitHelpCommand;
Undocumented in source.
_addImplicitHelpOption
bool _addImplicitHelpOption;
Undocumented in source.
_aliasNames
string[] _aliasNames;
Undocumented in source.
_allowExcessArguments
bool _allowExcessArguments;
Undocumented in source.
_allowExposeOptionValue
bool _allowExposeOptionValue;
Undocumented in source.
_allowVariadicMerge
bool _allowVariadicMerge;
Undocumented in source.
_argToOptNames
string[] _argToOptNames;
Undocumented in source.
_argsDescription
string[string] _argsDescription;
Undocumented in source.
_arguments
Argument[] _arguments;
Undocumented in source.
_called_sub
string _called_sub;
Undocumented in source.
_combineFlagAndOptionalValue
bool _combineFlagAndOptionalValue;
Undocumented in source.
_commands
Command[] _commands;
Undocumented in source.
_configOption
Option _configOption;
Undocumented in source.
_configPaths
string[] _configPaths;
Undocumented in source.
_defaultCommandName
string _defaultCommandName;
Undocumented in source.
_description
string _description;
Undocumented in source.
_execDir
string _execDir;
Undocumented in source.
_execFile
string _execFile;
Undocumented in source.
_execHandler
bool _execHandler;
Undocumented in source.
_export_map
Option[string] _export_map;
Undocumented in source.
_export_n_map
NegateOption[string] _export_n_map;
Undocumented in source.
_externalCmdHelpFlagMap
string[string] _externalCmdHelpFlagMap;
Undocumented in source.
_helpCommand
Command _helpCommand;
Undocumented in source.
_helpConfiguration
Help _helpConfiguration;
Undocumented in source.
_helpOption
Option _helpOption;
Undocumented in source.
_hidden
bool _hidden;
Undocumented in source.
_import_map
Option[string] _import_map;
Undocumented in source.
_import_n_map
NegateOption[string] _import_n_map;
Undocumented in source.
_inject_arr
string[] _inject_arr;
Undocumented in source.
_name
string _name;
Undocumented in source.
_negates
NegateOption[] _negates;
Undocumented in source.
_options
Option[] _options;
Undocumented in source.
_outputConfiguration
OutputConfiguration _outputConfiguration;
Undocumented in source.
_passThroughOptionValue
bool _passThroughOptionValue;
Undocumented in source.
_provide_arr
string[] _provide_arr;
Undocumented in source.
_selfPath
string _selfPath;
Undocumented in source.
_showHelpAfterError
bool _showHelpAfterError;
Undocumented in source.
_showSuggestionAfterError
bool _showSuggestionAfterError;
Undocumented in source.
_usage
string _usage;
Undocumented in source.
_version
string _version;
Undocumented in source.
_versionCommand
Command _versionCommand;
Undocumented in source.
_versionOption
Option _versionOption;
Undocumented in source.
argFlags
string[] argFlags;
Undocumented in source.
args
ArgVariant[] args;
Undocumented in source.
errorFlags
string[] errorFlags;
Undocumented in source.
immediately
bool immediately;
Undocumented in source.
jconfig
const(JSONValue)*[] jconfig;
Undocumented in source.
opts
OptionVariant[string] opts;
Undocumented in source.
parent
Command parent;
Undocumented in source.
rawFlags
string[] rawFlags;
Undocumented in source.
subCommand
Command subCommand;
Undocumented in source.
unknownFlags
string[] unknownFlags;
Undocumented in source.

Mixed In Members

From mixin SetActionFn!Action

action
Self action(Fn fn, bool immediately)
Undocumented in source. Be warned that the author may not have intended to support it.

Inherited Members

From EventManager

Self
alias Self = typeof(this)
Undocumented in source.
on
Self on(string eventName, EventCallback_1 callback)
Undocumented in source. Be warned that the author may not have intended to support it.
on
Self on(string eventName, EventCallback_2 callback)
Undocumented in source. Be warned that the author may not have intended to support it.
on
Self on(string eventName, EventCallback_3 callback)
Undocumented in source. Be warned that the author may not have intended to support it.
on
Self on(string eventName, EventCallback_4 callback)
Undocumented in source. Be warned that the author may not have intended to support it.
emit
bool emit(string eventName, string val)
Undocumented in source. Be warned that the author may not have intended to support it.
emit
bool emit(string eventName, string[] vals)
Undocumented in source. Be warned that the author may not have intended to support it.
emit
bool emit(string eventName)
Undocumented in source. Be warned that the author may not have intended to support it.
emit
bool emit(string eventName, bool isErrMode)
Undocumented in source. Be warned that the author may not have intended to support it.
removeEvent
bool removeEvent(string eventName)
Undocumented in source. Be warned that the author may not have intended to support it.

Meta