blesta / consoleation
A Command Line User Interface
1.0.0
2018-10-24 18:53 UTC
Requires
- php: >=5.3.0
Requires (Dev)
This package is auto-updated.
Last update: 2024-12-25 08:58:25 UTC
README
A simple library for output to command-line and setting a progress bar
Installation
Install via Composer
composer require blesta/consoleation
Basic Usage
Retrieve a single line from standard input
use Blesta/Consoleation/Console;
$console = new Console();
$line = $console->getLine();
Display content to standard output
use Blesta/Consoleation/Console;
$console = new Console();
$console->output("This is a single line with a blank new line\n");
Any number of additional arguments may be passed to output to perform string replacements via sprintf
.
use Blesta/Consoleation/Console;
$console = new Console();
$console->output("Would you like %s or %s?", "apples", "oranges");
Display a progress bar
use Blesta/Consoleation/Console;
$console = new Console();
$console->output("Performing the installation...\n");
$start = 1;
$finish = 5;
$progressBarCharLength = 50;
foreach (range($start, $finish) as $index => $number) {
$console->progressBar($index + 1, $finish, $progressBarCharLength);
sleep(1);
}