cliCommandNull

The null command is used as a place holder when a command is required, but a full class is not needed - e.g. for a long-option that is just a toggle or if you want to specify specific options within another command. This command is useful for creating extensive help for your cli application.

// document 'test' switch
$oApp = new cliApplication('example', 'A simple example.');
$oRequest = cliRequest::getInstance()->setApplication($oApp);
$oApp->getCommandChain()
    ->addCommand(
        new cliCommandNull($oRequest, 'test', 'Help for switch test', false, true, true)
    )
$oApp->execute($oRequest);

// usage within a command, in this case the testCommand from the test system:
new testCommand(
    $oRequest, new cliCommandChain(
        array(
            new cliCommandNull($oRequest, 'all', 'Run all test cases', false, false),
            new cliCommandNull($oRequest, 'package',
                "Run test case(s) for specific package. Requires 
 and optionally \ne.g. test package 
 ", true, false, false
            )
        )
    )
)

Methods

public __construct($inRequest, $inCommand, $inHelpText, [$inRequiresValue = false], [$inIsSwitch = true], [$inIsOptional = true])

Creates a new null command that has no execute body.

The command will be processed the same as any other argument, but does not cause the application to halt. Used when a long option (toggle) is wanted or for disposable commands that do not require a concrete implementation. $inIsSwitch if set to false causes the command to appear as an instead of as <--switch>. Default is as a switch. By default all null commands are "optional" which will cause them to be flagged as optional in the help messages.

public execute()

Executes the command


Inherited Methods

<  1  >