Library
Class

Library\CommandLine\AbstractCommandLineController

abstract class AbstractCommandLineController implements CommandLineControllerInterface

Basic command line controller

Any command line controller must extend this abstract class.

It defines some basic command line options that you must not overwrite in your child class:

Properties

static string $_name This must be over-written in any child class
static string $_version This must be over-written in any child class

Methods

__construct(array $options = array())

string __toString()

Magic distribution when printing object

distribute()

Distribution of the work

AbstractCommandLineController setDebug(bool $dbg = true)

$this setVerbose(bool $vbr = true)

$this setForce(bool $frc = true)

$this setInteractive(bool $frc = true)

$this setQuiet()

$this addDoneMethod(string $_cls_meth)

array getDoneMethods()

AbstractCommandLineController setScript(string $script_name)

Set the current command line script called

string getScript()

Get the current command line script called

AbstractCommandLineController setParameters(array $params)

Set the command line parameters

array getParameters()

Get the parameters collection

runHelpCommand($opt = null)

List of all options and features of the command line tool ; for some commands, a specific help can be available, running --command --help Some command examples are purposed running --console --help

runVerboseCommand()

Run the command line in verbose mode, writing some information on screen (default is )

runQuietCommand()

Run the command line in quiet mode, trying to not write anything on screen (default is )

runDebugCommand()

Run the command line in debug mode, writing some scripts information during runtime (default is )

runForceCommand()

Run the command line in forced mode ; any choice will be set on default value if so

runInteractiveCommand()

Run the command line in interactive mode ; any choice will be prompted if possible

runVersionCommand()

Get versions of system environment

$this write(null $str = null, bool $new_line = true)

Format and write a string to STDOUT

$this error(null $str = null, int $status = 1, bool $new_line = true)

Format and write an error message to STDOUT (or STDERR) and exits with status $status

$this parseAndWrite(string $str, null $type = null, bool $spaced = false)

Parse, format and write a message to STDOUT

$this writeError(string $str)

$this writeThinError(string $str)

$this writeInfo(string $str)

$this writeComment(string $str)

$this writeHighlight(string $str)

$this writeBreak()

$this writeStop()

$this verboseWrite(null $str = null, bool $new_line = true)

Write a string only in verbose mode

$this debugWrite(null $str = null, bool $new_line = true)

Write a string only in debug mode

string prompt(string|null $str = null, mixed|null $default = null)

Prompt user input

string getPrompt()

Get last user input

writeIntro()

getVersionString()

writeNothingToDo()

runArgumentHelp($arg = null)

usage($opt = null)

getopt()

getOptionMethod($arg = null)

getOptionDescription($arg = null)

getOptionHelp($arg = null)

Details

at line 175
public __construct(array $options = array())

Parameters

array $options

at line 219
public string __toString()

Magic distribution when printing object

Return Value

string

at line 228
public distribute()

Distribution of the work

at line 248
public AbstractCommandLineController setDebug(bool $dbg = true)

Parameters

bool $dbg

Return Value

AbstractCommandLineController

at line 259
public $this setVerbose(bool $vbr = true)

Parameters

bool $vbr

Return Value

$this

at line 269
public $this setForce(bool $frc = true)

Parameters

bool $frc

Return Value

$this

at line 279
public $this setInteractive(bool $frc = true)

Parameters

bool $frc

Return Value

$this

at line 290
public $this setQuiet()

Return Value

$this

See also

self::setVerbose()
self::setDebug()

at line 301
public $this addDoneMethod(string $_cls_meth)

Parameters

string $_cls_meth

Return Value

$this

at line 310
public array getDoneMethods()

Return Value

array

at line 321
public AbstractCommandLineController setScript(string $script_name)

Set the current command line script called

Parameters

string $script_name The script name

Return Value

AbstractCommandLineController

at line 332
public string getScript()

Get the current command line script called

Return Value

string

at line 343
public AbstractCommandLineController setParameters(array $params)

Set the command line parameters

Parameters

array $params The collection of parameters

Return Value

AbstractCommandLineController

at line 354
public array getParameters()

Get the parameters collection

Return Value

array

at line 368
public runHelpCommand($opt = null)

List of all options and features of the command line tool ; for some commands, a specific help can be available, running --command --help Some command examples are purposed running --console --help

Parameters

$opt

at line 391
public runVerboseCommand()

Run the command line in verbose mode, writing some information on screen (default is )

at line 399
public runQuietCommand()

Run the command line in quiet mode, trying to not write anything on screen (default is )

at line 407
public runDebugCommand()

Run the command line in debug mode, writing some scripts information during runtime (default is )

at line 415
public runForceCommand()

Run the command line in forced mode ; any choice will be set on default value if so

at line 423
public runInteractiveCommand()

Run the command line in interactive mode ; any choice will be prompted if possible

at line 431
public runVersionCommand()

Get versions of system environment

at line 460
public $this write(null $str = null, bool $new_line = true)

Format and write a string to STDOUT

Parameters

null $str
bool $new_line

Return Value

$this

at line 474
public $this error(null $str = null, int $status = 1, bool $new_line = true)

Format and write an error message to STDOUT (or STDERR) and exits with status $status

Parameters

null $str
int $status
bool $new_line

Return Value

$this

at line 488
public $this parseAndWrite(string $str, null $type = null, bool $spaced = false)

Parse, format and write a message to STDOUT

Parameters

string $str
null $type
bool $spaced

Return Value

$this

at line 503
public $this writeError(string $str)

Parameters

string $str

Return Value

$this

at line 514
public $this writeThinError(string $str)

Parameters

string $str

Return Value

$this

at line 526
public $this writeInfo(string $str)

Parameters

string $str

Return Value

$this

at line 536
public $this writeComment(string $str)

Parameters

string $str

Return Value

$this

at line 547
public $this writeHighlight(string $str)

Parameters

string $str

Return Value

$this

at line 556
public $this writeBreak()

Return Value

$this

at line 565
public $this writeStop()

Return Value

$this

at line 585
public $this verboseWrite(null $str = null, bool $new_line = true)

Write a string only in verbose mode

Parameters

null $str
bool $new_line

Return Value

$this

at line 598
public $this debugWrite(null $str = null, bool $new_line = true)

Write a string only in debug mode

Parameters

null $str
bool $new_line

Return Value

$this

at line 611
public string prompt(string|null $str = null, mixed|null $default = null)

Prompt user input

Parameters

string|null $str
mixed|null $default

Return Value

string

at line 624
public string getPrompt()

Get last user input

Return Value

string

at line 641
public writeIntro()

at line 651
public getVersionString()

at line 664
public writeNothingToDo()

at line 671
public runArgumentHelp($arg = null)

Parameters

$arg

at line 684
public usage($opt = null)

Parameters

$opt

at line 788
public getopt()

at line 795
public getOptionMethod($arg = null)

Parameters

$arg

at line 802
public getOptionDescription($arg = null)

Parameters

$arg

at line 807
public getOptionHelp($arg = null)

Parameters

$arg