Cli
Terminal output and input for CLI commands: messages, tables, progress bars and prompts.
- args Splits arguments into [positional, flags]: `--name=value` is a flag's value, a bare `--name` is true.
- br Prints an empty line.
- climate The CLImate instance behind the output methods.
- confirm Asks a yes or no question.
- docblock The first docblock of a command file, as its summary line and full body.
- error Prints an error line.
- info Prints an informational line.
- input Asks a question and returns the answer.
- namespaceHelp Lists the commands in a namespace with their summaries and exits.
- out Prints a line.
- password Asks for input without echoing it.
- progress A progress bar counting up to $total.
- status Overwrites the current terminal line, for a live counter when there is no total to size a progress bar by.
- success Prints a success line.
- table Prints rows as a table.
- usage Prints a command's docblock as its help and exits.
- wantsHelp Whether the arguments include `--help` or `-h`.
- warning Prints a warning line.
Methods
Cli::args(array $args): array
Splits arguments into [positional, flags]: `--name=value` is a flag's value, a bare `--name` is true.
Parameters (1)
| $args | array |
Returns array
phlat/src/Toolkit/Cli.php:104
Cli::climate(): CLImate
The CLImate instance behind the output methods.
Returns CLImate
phlat/src/Toolkit/Cli.php:20
Cli::confirm(string $prompt): bool
Asks a yes or no question.
Parameters (1)
| $prompt | string |
Returns bool
phlat/src/Toolkit/Cli.php:86
Cli::docblock(string $file): array
The first docblock of a command file, as its summary line and full body.
Parameters (1)
| $file | string |
Returns array
phlat/src/Toolkit/Cli.php:121
Cli::error(string $message): void
Prints an error line.
Parameters (1)
| $message | string |
phlat/src/Toolkit/Cli.php:50
Cli::info(string $message): void
Prints an informational line.
Parameters (1)
| $message | string |
phlat/src/Toolkit/Cli.php:32
Cli::input(string $prompt): string
Asks a question and returns the answer.
Parameters (1)
| $prompt | string |
Returns string
phlat/src/Toolkit/Cli.php:80
namespaceHelp
exitsCli::namespaceHelp(string $namespace, string $dir): never
Lists the commands in a namespace with their summaries and exits.
Parameters (2)
| $namespace | string | |
| $dir | string |
Returns never
phlat/src/Toolkit/Cli.php:171
Cli::out(string $message): void
Prints a line.
Parameters (1)
| $message | string |
phlat/src/Toolkit/Cli.php:26
Cli::password(string $prompt): string
Asks for input without echoing it.
Parameters (1)
| $prompt | string |
Returns string
phlat/src/Toolkit/Cli.php:92
Cli::progress(int $total): Progress
A progress bar counting up to $total.
Parameters (1)
| $total | int |
Returns Progress
phlat/src/Toolkit/Cli.php:68
Cli::status(string $message): void
Overwrites the current terminal line, for a live counter when there is no total to size a progress bar by.
End it with br().
Parameters (1)
| $message | string |
phlat/src/Toolkit/Cli.php:62
Cli::success(string $message): void
Prints a success line.
Parameters (1)
| $message | string |
phlat/src/Toolkit/Cli.php:38
Cli::table(array $data): void
Prints rows as a table.
Parameters (1)
| $data | array |
phlat/src/Toolkit/Cli.php:56
usage
exitsCli::usage(string $file): never
Prints a command's docblock as its help and exits.
Parameters (1)
| $file | string |
Returns never
phlat/src/Toolkit/Cli.php:153
Cli::wantsHelp(array $args): bool
Whether the arguments include `--help` or `-h`.
Parameters (1)
| $args | array |
Returns bool
phlat/src/Toolkit/Cli.php:98
Cli::warning(string $message): void
Prints a warning line.
Parameters (1)
| $message | string |
phlat/src/Toolkit/Cli.php:44