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:
- "h | help" : get a usage information,
- "v | verbose" : increase verbosity of the execution (written strings must be handled in your scripts),
- "x | debug" : execute the script in "debug" mode (must write actions before executing them),
- "q | quiet" : turn verbosity totally off during the execution (only errors and informations will be written),
- "f | force" : force some actions (avoid interactions),
- "i | interactive" : increase interactivity of the execution,
- "version" : get some version information about running environment.
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 |
||
runQuietCommand()
Run the command line in |
||
runDebugCommand()
Run the command line in |
||
runForceCommand()
Run the command line in |
||
runInteractiveCommand()
Run the command line in |
||
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 |
|
$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())
at line 219
public string
__toString()
Magic distribution when printing object
at line 228
public
distribute()
Distribution of the work
at line 248
public AbstractCommandLineController
setDebug(bool $dbg = true)
at line 259
public $this
setVerbose(bool $vbr = true)
at line 269
public $this
setForce(bool $frc = true)
at line 279
public $this
setInteractive(bool $frc = true)
at line 290
public $this
setQuiet()
at line 301
public $this
addDoneMethod(string $_cls_meth)
at line 310
public array
getDoneMethods()
at line 321
public AbstractCommandLineController
setScript(string $script_name)
Set the current command line script called
at line 332
public string
getScript()
Get the current command line script called
at line 343
public AbstractCommandLineController
setParameters(array $params)
Set the command line parameters
at line 354
public array
getParameters()
Get the parameters collection
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
at line 391
public
runVerboseCommand()
Run the command line in
at line 399
public
runQuietCommand()
Run the command line in
at line 407
public
runDebugCommand()
Run the command line in
at line 415
public
runForceCommand()
Run the command line in
at line 423
public
runInteractiveCommand()
Run the command line in
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
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
at line 488
public $this
parseAndWrite(string $str, null $type = null, bool $spaced = false)
Parse, format and write a message to STDOUT
at line 503
public $this
writeError(string $str)
at line 514
public $this
writeThinError(string $str)
at line 526
public $this
writeInfo(string $str)
at line 536
public $this
writeComment(string $str)
at line 547
public $this
writeHighlight(string $str)
at line 556
public $this
writeBreak()
at line 565
public $this
writeStop()
at line 585
public $this
verboseWrite(null $str = null, bool $new_line = true)
Write a string only in verbose mode
at line 598
public $this
debugWrite(null $str = null, bool $new_line = true)
Write a string only in debug mode
at line 611
public string
prompt(string|null $str = null, mixed|null $default = null)
Prompt user input
at line 624
public string
getPrompt()
Get last user input
at line 641
public
writeIntro()
at line 651
public
getVersionString()
at line 664
public
writeNothingToDo()
at line 671
public
runArgumentHelp($arg = null)
at line 684
public
usage($opt = null)
at line 788
public
getopt()
at line 795
public
getOptionMethod($arg = null)
at line 802
public
getOptionDescription($arg = null)
at line 807
public
getOptionHelp($arg = null)