vsouz4/print-bash

Print stuff on bash


License
GPL-3.0

Documentation

print-bash

Printing stuff on bash with colors, bold etc.

<?php

include 'vendor/autoload.php';

use PrintBash\Text;
use PrintBash\Formatter;
use PrintBash\Colors;
use PrintBash\Printer;

use BashIO\Interactor;
use BashIO\In;
use BashIO\Out;

$text = (new Text('test'))
    ->bold()
    ->underline()
    ->textColor(Colors::RED)
    ->backgroundColor(Colors::BLUE);

// using bash io interactor now
$interactor = new Interactor(new In(), new Out());

// only print it with new line
$interactor->writeln($text);

// or with sprintf formats
$interactor->writeln((new Formatter('Something: %s'))->addText($text));

// or with multiple texts to print at the same time
$interactor->writeln((new Formatter('Something else: %s %s'))->addTexts([$text, $text]));
<?php

include 'vendor/autoload.php';

use PrintBash\Progress;

(new Progress(function($i) {
    usleep(10000);
}))->run();

(new Progress(function($i) {
    usleep(10000);
}, 1000, '-'))->run();

(new Progress(function($i) {
    usleep(10000);
}, 300, '.', 150))->run();

(new Progress(function($i) {
    usleep(10000);
}))->setTemplate("(%s%s)\n%s%%")->run();