Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

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