CLI class
Framework\CLI\CLI
Class CLI.
Defined in libraries/cli/src/CLI.php
Properties #
- $reset
- -
$reset
Methods #
- beep()
- Performs audible beep alarms.
- box()
- Writes a message box.
- clear()
- Clear the terminal screen.
- error()
- Writes a message to STDERR and optionally exit with a custom code.
- getInput()
- Get user input.
- getWidth()
- Get the screen width.
- info()
- Writes an informational message.
- isWindows()
- Tells if it is running on a Windows OS.
- liveLine()
- Creates a "live line".
- newLine()
- Prints a new line in the output.
- path()
- Join path segments using the current platform separator.
- prompt()
- Prompt a question.
- secret()
- Prompt a question with secret answer.
- strlen()
- Calculate the multibyte length of a text without style characters.
- style()
- Applies styles to a text.
- success()
- Writes a success message.
- supportsAnsi()
- Tells if the current terminal likely supports ANSI escape sequences.
- table()
- Creates a well formatted table.
- wrap()
- Displays text wrapped to a certain width.
- write()
- Write a text in the output.
beep()
Performs audible beep alarms.
- int $times - How many times should the beep be played
- int $usleep - Interval in microseconds
box()
Writes a message box.
- array|string $lines - One line as string or multi-lines as array
- \Framework\CLI\Styles\BackgroundColor|string $background - Background color
- \Framework\CLI\Styles\ForegroundColor|string $color - Foreground color
clear()
Clear the terminal screen.
error()
Writes a message to STDERR and optionally exit with a custom code.
- string $message - The error message
- ?int $exitCode - Set null to do not exit
getInput()
Get user input.
NOTE: It is possible pass multiple lines ending each line with a backslash.
- string $prepend - Text prepended in the input. Used internally to allow multiple lines
getWidth()
Get the screen width.
- int $default
info()
Writes an informational message.
- string $text - The message to be written
isWindows()
Tells if it is running on a Windows OS.
liveLine()
Creates a "live line".
Erase the current line, move the cursor to the beginning of the line and
writes a text.
- string $text - The text to be written
- bool $finalize - If true the "live line" activity ends, creating a new line after the text
newLine()
Prints a new line in the output.
- int $lines - Number of lines to be printed
path()
Join path segments using the current platform separator.
- string $segments
prompt()
Prompt a question.
- string $question - The question to prompt
- array|string|null $options - Answer options. If an array is set, the default answer is the first value. If is a string, it will be the default.
secret()
Prompt a question with secret answer.
- string $question - The question to prompt
strlen()
Calculate the multibyte length of a text without style characters.
- string $text - The text being checked for length
style()
Applies styles to a text.
- string $text - The text to be styled
- \Framework\CLI\Styles\ForegroundColor|string|null $color - Foreground color
- \Framework\CLI\Styles\BackgroundColor|string|null $background - Background color
- array $formats - The text formats
success()
Writes a success message.
- string $text - The message to be written
supportsAnsi()
Tells if the current terminal likely supports ANSI escape sequences.
table()
Creates a well formatted table.
- array $tbody - Table body rows
- array $thead - Table head fields
wrap()
Displays text wrapped to a certain width.
- string $text
- ?int $width
write()
Write a text in the output.
Optionally with styles and width wrapping.
- string $text - The text to be written
- \Framework\CLI\Styles\ForegroundColor|string|null $color - Foreground color
- \Framework\CLI\Styles\BackgroundColor|string|null $background - Background color
- ?int $width - Width to wrap the text. Null to do not wrap.