-
-
Notifications
You must be signed in to change notification settings - Fork 75
/
Functions.php
63 lines (55 loc) · 1.33 KB
/
Functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
declare(strict_types=1);
namespace Termwind;
use Closure;
use Symfony\Component\Console\Output\OutputInterface;
use Termwind\Repositories\Styles as StyleRepository;
use Termwind\ValueObjects\Style;
use Termwind\ValueObjects\Styles;
if (! function_exists('Termwind\renderUsing')) {
/**
* Sets the renderer implementation.
*/
function renderUsing(OutputInterface|null $renderer): void
{
Termwind::renderUsing($renderer);
}
}
if (! function_exists('Termwind\style')) {
/**
* Creates a new style.
*
* @param (Closure(Styles $renderable, string|int ...$arguments): Styles)|null $callback
*/
function style(string $name, Closure $callback = null): Style
{
return StyleRepository::create($name, $callback);
}
}
if (! function_exists('Termwind\render')) {
/**
* Render HTML to a string.
*/
function render(string $html): void
{
(new HtmlRenderer)->render($html);
}
}
if (! function_exists('Termwind\terminal')) {
/**
* Returns a Terminal instance.
*/
function terminal(): Terminal
{
return new Terminal;
}
}
if (! function_exists('Termwind\ask')) {
/**
* Renders a prompt to the user.
*/
function ask(string $question): string|null
{
return (new Question)->ask($question);
}
}