Lines Matching +full:check +full:- +full:pass -(+path:inc +path:lang) -(+path:lib +path:plugins +path:lang) -(+path:lib +path:tpl +path:dokuwiki +path:lang)

1 # PHP-CLI
3 PHP-CLI is a simple library that helps with creating nice looking command line scripts.
7 - **option parsing**
8 - **help page generation**
9 - **automatic width adjustment**
10 - **colored output**
11 - **optional PSR3 compatibility**
13 It is lightweight and has **no 3rd party dependencies**. Note: this is for non-interactive scripts only. It has no readline or similar support.
19 ```php composer.phar require splitbrain/php-cli```
37 $options->setHelp('A very minimal example that does nothing but print a version');
38 $options->registerOption('version', 'print version', 'v');
44 if ($options->getOpt('version')) {
45 $this->info('1.0.0');
47 echo $options->help();
53 $cli->run();
61 - create a class and ``extend splitbrain\phpcli\CLI``
62 - implement the ```setup($options)``` method and register options, arguments, commands and set help texts
63 - ``$options->setHelp()`` adds a general description
64 - ``$options->registerOption()`` adds an option
65 - ``$options->registerArgument()`` adds an argument
66 - ``$options->registerCommand()`` adds a sub command
67 - implement the ```main($options)``` method and do your business logic there
68 - ``$options->getOpts`` lets you access set options
69 - ``$options->getArgs()`` returns the remaining arguments after removing the options
70 - ``$options->getCmd()`` returns the sub command the user used
71 - instantiate your class and call ```run()``` on it
73 More examples can be found in the examples directory. Please refer to the [API docs](https://splitbrain.github.io/php-cli/)
79 exit the programm with a non-zero exit code. You can disable this behaviour and catch all exceptions yourself by
90 then uses terminal colors. You can always suppress colored output by passing ``--no-colors`` to your scripts.
94 ``error()`` (red) or ``fatal()`` (red). The latter will also exit the programm with a non-zero exit code.
96 For more complex coloring you can access the color class through ``$this->colors`` in your script. The ``wrap()`` method
99 The table formatter allows coloring full columns. To use that mechanism pass an array of colors as third parameter to
100 its ``format()`` method. Please note that you can not pass colored texts in the second parameters (text length calculation
116 - fixed width in characters by providing an integer (eg. ``15``)
117 - precentages by provifing an integer and a percent sign (eg. ``25%``)
118 - a single fluid "rest" column marked with an asterisk (eg. ``*``)
126 The table formatter is used for the automatic help screen accessible when calling your script with ``-h`` or ``--help``.
128 ## PSR-3 Logging
130 The CLI class is a fully PSR-3 compatible logger (printing colored log data to STDOUT and STDERR). This is useful when
133 If you need to pass a class implementing the `Psr\Log\LoggerInterface` you can do so by inheriting from one of the two provided classes implementing this interface instead of `splitbrain\phpcli\CLI`.
140 Note: if your backend code calls for a PSR-3 logger but does not actually type check for the interface (AKA being LoggerAware only) you can also just pass an instance of `splitbrain\phpcli\CLI`.
144 You can adjust the verbosity of your CLI tool using the `--loglevel` parameter. Supported loglevels are the PSR-3
150 * success (this is not defined in PSR-3)
159 Convenience methods for all log levels are available. Placeholder interpolation as described in PSR-3 is available, too.