[ Index ] |
PHP Cross Reference of DokuWiki |
[Source view] [Print] [Project Stats]
Class DokuCLI All DokuWiki commandline scripts should inherit from this class and implement the abstract methods.
Author: | Andreas Gohr |
File Size: | 656 lines (20 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
DokuCLI_Colors:: (6 methods):
__construct()
enable()
disable()
ptln()
set()
reset()
DokuCLI_Options:: (12 methods):
__construct()
setHelp()
registerArgument()
registerCommand()
registerOption()
checkArguments()
parseOptions()
getOpt()
getCmd()
help()
readPHPArgv()
tableFormat()
DokuCLI_Exception:: (1 method):
__construct()
Class: DokuCLI_Colors - X-Ref
Class DokuCLI_Colors__construct() X-Ref |
Constructor Tries to disable colors for non-terminals |
enable() X-Ref |
enable color output |
disable() X-Ref |
disable color output |
ptln($line, $color, $channel = STDOUT) X-Ref |
Convenience function to print a line in a given color param: string $line param: string $color param: resource $channel |
set($color) X-Ref |
Set the given color for consecutive output param: string $color one of the supported color names |
reset() X-Ref |
reset the terminal color |
Class: DokuCLI_Options - X-Ref
Class DokuCLI_Options__construct() X-Ref |
Constructor |
setHelp($help) X-Ref |
Sets the help text for the tool itself param: string $help |
registerArgument($arg, $help, $required = true, $command = '') X-Ref |
Register the names of arguments for help generation and number checking This has to be called in the order arguments are expected param: string $arg argument name (just for help) param: string $help help text param: bool $required is this a required argument param: string $command if theses apply to a sub command only |
registerCommand($command, $help) X-Ref |
This registers a sub command Sub commands have their own options and use their own function (not main()). param: string $command param: string $help |
registerOption($long, $help, $short = null, $needsarg = false, $command = '') X-Ref |
Register an option for option parsing and help generation param: string $long multi character option (specified with --) param: string $help help text for this option param: string|null $short one character option (specified with -) param: bool|string $needsarg does this option require an argument? give it a name here param: string $command what command does this option apply to |
checkArguments() X-Ref |
Checks the actual number of arguments against the required number Throws an exception if arguments are missing. Called from parseOptions() |
parseOptions() X-Ref |
Parses the given arguments for known options and command The given $args array should NOT contain the executed file as first item anymore! The $args array is stripped from any options and possible command. All found otions can be accessed via the getOpt() function Note that command options will overwrite any global options with the same name |
getOpt($option, $default = false) X-Ref |
Get the value of the given option Please note that all options are accessed by their long option names regardless of how they were specified on commandline. Can only be used after parseOptions() has been run return: bool|string param: string $option param: bool|string $default what to return if the option was not set |
getCmd() X-Ref |
Return the found command if any return: string |
help() X-Ref |
Builds a help screen from the available options. You may want to call it from -h or on error return: string |
readPHPArgv() X-Ref |
Safely read the $argv PHP array across different PHP configurations. Will take care on register_globals and register_argc_argv ini directives return: array the $argv PHP array or PEAR error if not registered |
tableFormat($widths, $texts) X-Ref |
Displays text in multiple word wrapped columns return: string param: int[] $widths list of column widths (in characters) param: string[] $texts list of texts for each column |
Class: DokuCLI_Exception - X-Ref
Class DokuCLI_Exception__construct($message = "", $code = 0, Exception $previous = null) X-Ref |
param: string $message The Exception message to throw. param: int $code The Exception code param: Exception $previous The previous exception used for the exception chaining. |
__construct() X-Ref |
constructor Initialize the arguments, set up helper classes and set up the CLI environment |
run() X-Ref |
Execute the CLI program Executes the setup() routine, adds default options, initiate the options parsing and argument checking and finally executes main() |
fatal($error) X-Ref |
Exits the program on a fatal error param: Exception|string $error either an exception or an error message |
error($string) X-Ref |
Print an error message param: string $string |
success($string) X-Ref |
Print a success message param: string $string |
info($string) X-Ref |
Print an info message param: string $string |