Documentation

Cli
in package
implements Horde_Cli_Modular_Module Uses HordectlModuleTrait, HasModulesTrait

Hordectl CLI Root Module

The basic idea of hordectl is a very modular approach. Everything is either a leaf module or a parent module regardless of its level.

Apart from the static Cli::main method which handles all the initial setup, Horde\Hordectl\Cli is just a parent module like any other

Modules know their runtime parents and their parent's parsed config but they may appear in any other part of the tree if called by another frontend

It is safe for a parent to assume its builtin children exist (like the help submodule)

In fact, hordectl is a spinoff from an application specific solution

Interfaces, Classes, Traits and Enums

Horde_Cli_Modular_Module

Table of Contents

$_modules  : mixed
$_parentModule  : mixed
$_parsed  : mixed
$_parser  : mixed
$_positional  : mixed
__construct()  : mixed
count()  : int
Implementation of Countable count() method. Returns the number of modules.
getBaseOptions()  : mixed
getIterator()  : mixed
getOptionGroupDescription()  : mixed
getOptionGroupOptions()  : mixed
getOptionGroupTitle()  : mixed
getParentModule()  : Horde_Cli_Modular_Module
getPositionalArgs()  : array<string|int, mixed>
Get the list of possible arguments for this module's position
getTitle()  : string
Default implementation of getTitle
getUsage()  : mixed
handle()  : bool
handleCommandline()  : mixed
Handle commandline given to this module
hasOptionGroup()  : mixed
isRootModule()  : mixed
listModules()  : array<string|int, mixed>
List the available modules.
main()  : mixed
setParentModule()  : mixed
_prepareModular()  : Horde_Cli_Modular
Prepare the modular CLI instance.
_initModules()  : mixed
Initialize the list of direct submodules to the current module

Properties

Methods

__construct()

public __construct(Horde_Injector $dependencies) : mixed
Parameters
$dependencies : Horde_Injector
Return values
mixed

count()

Implementation of Countable count() method. Returns the number of modules.

public count() : int
Return values
int

Number of modules.

getOptionGroupDescription()

public getOptionGroupDescription() : mixed
Return values
mixed

getOptionGroupOptions()

public getOptionGroupOptions([mixed $action = null ]) : mixed
Parameters
$action : mixed = null
Return values
mixed

getParentModule()

public getParentModule() : Horde_Cli_Modular_Module
Return values
Horde_Cli_Modular_Module

getPositionalArgs()

Get the list of possible arguments for this module's position

public getPositionalArgs() : array<string|int, mixed>

If a module implements a positional, it will be extracted before the commandline is evaluated

Default implementation, override as needed

Return values
array<string|int, mixed>

getTitle()

Default implementation of getTitle

public getTitle() : string

Override this as needed

Return values
string

The title of the module

handle()

public handle([array<string|int, mixed> $argv = [] ]) : bool
Parameters
$argv : array<string|int, mixed> = []
Return values
bool

handleCommandline()

Handle commandline given to this module

public handleCommandline(array<string|int, mixed> $argv) : mixed

Commandline options and keywords belonging to parent modules have already been removed. The module's PositionalArgs will be checked in second position and removed. Options will only be regarded until the following positional argument.

Position 0 in argv is assumed to be the program name // non-interspersed parser may not tolerate position 0

Parameters
$argv : array<string|int, mixed>
Return values
mixed

listModules()

List the available modules.

public listModules() : array<string|int, mixed>
Return values
array<string|int, mixed>

The list of modules.

main()

public static main([array<string|int, mixed> $parameters = array() ]) : mixed
Parameters
$parameters : array<string|int, mixed> = array()
Return values
mixed

setParentModule()

public setParentModule(Horde_Cli_Modular_Module $module) : mixed
Parameters
$module : Horde_Cli_Modular_Module
Return values
mixed

_prepareModular()

Prepare the modular CLI instance.

protected static _prepareModular(Horde_Injector $dependencies) : Horde_Cli_Modular

Adapted from Horde git-tools CLI

Parameters
$dependencies : Horde_Injector

The dependency container.

Return values
Horde_Cli_Modular

The modular CLI object.

_initModules()

Initialize the list of direct submodules to the current module

private _initModules(Horde_Injector $dependencies, string $prefix, string $directory[, array<string|int, mixed> $exclude = [] ]) : mixed

First check a certain folder for files and assume they adhere to a certain class name schema TODO: Then check all registered apps for a list of well known classnames

Initialize all modules and assign them their parent

Parameters
$dependencies : Horde_Injector
$prefix : string
$directory : string
$exclude : array<string|int, mixed> = []
Return values
mixed

Search results