gevman/interactive-cli

PHP interactive CLI

1.0.0 2017-04-11 14:14 UTC

This package is auto-updated.

Last update: 2024-11-21 03:51:30 UTC


README

Latest Stable Version Latest Unstable Version License

Installation (using composer)

composer require gevman/interactive-cli

Class Gevman\Cli\Cli

bool confirm(string $prompt [, bool $default = true])

Interactive confirm - returns user selected value (Y=true, N=false)
  • $prompt - prompt message
  • $default - default value

void input(&$input [, string $message = ''] [, bool $required = false])

Interactive prompt for user input
  • $prompt - prompt message
  • $default - default value

Gevman\Cli\CliOutput output(string $str [, mixed $_ = null])

Outputs message
  • $str - message or pattern for sprintf
  • $_ - parameters for sprintf

Class Gevman\Cli\CliOutput

Gevman\Cli\CliOutput success()

Marks output green

Gevman\Cli\CliOutput warning()

Marks output Yellow

Gevman\Cli\CliOutput error()

Marks output Red

Gevman\Cli\CliOutput note()

Marks output Blue

Gevman\Cli\CliOutput endl()

Line break

Gevman\Cli\CliOutput cl()

Clear current line

void progressBar(mixed $all [, string $additionalInfo = ''])

Displays interactive progressbar (message should be current key)
  • $all - count of all
  • $additionalInfo - displays additional Info for each step
require '/path/to/autoload.php';

use Gevman\Cli\Cli;

//basic example
Cli::output('%s - %s', 'hello', 'world')->note()->endl()->output('yesimum')->error()->endl()->endl();

//pregressbar example
$all = 100000;
for ($step = 0; $step < 100000; $step++) {
    Cli::output($step + 1)->progressBar($all, $step);
}