-
-
Notifications
You must be signed in to change notification settings - Fork 1
Console
StefansArya edited this page Apr 18, 2019
·
5 revisions
If you want to use the console feature, you need to defined your commands on/routes/console.php
.
You may need to import this feature on top of your code.
use \Scarlets\Console;
Console::command($pattern, $callback, $info = '');
# Example
Console::command('echo {*}', function($message){
echo($message);
});
Console::hiddenInput();
# Example
Console::command('input', function(){
echo("Type something invisible: ");
print_r("Result: ".Console::hiddenInput());
}, 'Type something');
Console::chalk($text, $color);
// The color can be either:
// black, red, green, yellow,
// blue, magenta, cyan
# Example
Console::command('echo {*}', function($message){
echo(Console::chalk("Computer> $message", 'yellow'));
});
Console::args($pattern, $callback);
# Example
Console::command('echo {*}', function($all){
Console::args('{0} {1}', function($name, $message){
echo("$name> $message");
});
// Check if args above was not being called
if(!Console::$found)
echo "Computer> $all";
});
Console::help($name, $callback = 'or text');
# Example
Console::help('echo', "Type 'echo (anything here)' to get echo back.");
Console::clear();
// Check if the framework was turned on interactive CLI
\Scarlets::$interactiveCLI === true;
// Check if the framework was turned on the console feature
\Scarlets::$isConsole === true;
// Check if the script is started from shell/cli
Console::isConsole() === true;
This will help you to create table for your data.
Console::table($array);
# Example
Console::table([
['No', 'Name', 'Email'],
[1, 'Alex', 'alex@mail.com'],
[2, 'Brian', 'brian@yahoo.com']
]);