It's like Tailwind CSS, but for the console.

Related tags

Command Line tailcli
Overview

GitHub Workflow Status (master) Total Downloads Latest Version License


Tailcli allows building unique, beautiful command-line applications, using tailwind classes. It's like Tailwind CSS, but for the console.

Installation & Usage

Requires PHP 8.0+

Require Tailcli using Composer:

composer require nunomaduro/tailcli --dev

Examples

use NunoMaduro\TailCli\TailCli;

TailCli::line('foo', 'pl-2'); // '  foo';
TailCli::line('foo')->pl2(); // '  foo';
TailCli::line('foo')->pl(2); // '  foo';

Tailcli is an open-sourced software licensed under the MIT license.

Comments
  • [feat] autocomplete for questions

    [feat] autocomplete for questions

    This PR will add autocomplete feature for ask/Question

    here's the resulting prompt:

    https://user-images.githubusercontent.com/8792274/188404964-8d521a32-3a3d-4a7d-8e54-2e99d5c886da.mp4

    opened by fabio-ivona 14
  • Add support for table tags

    Add support for table tags

    render(<<<'HTML'
    <table style="box-double">
        <thead title="Books" class="bg-red text-color-white px-10">
            <tr>
                <th align="right">ISBN</th>
                <th>Title</th>
                <th>Author</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <th align="right">99921-58-10-7</th>
                <td>Divine Comedy</td>
                <td align="right">Dante Alighieri</td>
            </tr>
            <tr border="1">
                <th class="bg-blue text-color-red" align="right">9971-5-0210-0</th>
                <td>A Tale of Two Cities</td>
                <td align="right">Charles Dickens</td>
            </tr>
            <tr>
                <th align="right">960-425-059-0</th>
                <td>The Lord of the Rings</td>
                <td align="right">J. R. R. Tolkien</td>
            </tr>
            <tr>
                <th align="right">80-902734-1-6</th>
                <td>And Then There Were None</td>
                <td rowspan="2" align="right">Dante Alighieri\nspans multiple rows</td>
            </tr>
            <tr>
                <th align="right">978-052156781</th>
                <td>De Monarchia</td>
            </tr>
        </tbody>
        <tfoot title="Page 1/2" class="mx-5 bg-blue">
            <tr>
                <th colspan="3">This value spans 3 columns.</th>
            </tr>
        </tfoot>
    </table>
    HTML);
    

    Will render table

    opened by butschster 13
  • feat: Add `setColors`

    feat: Add `setColors`

    This PR adds the capability to overwrite existent colors or create new colors.

    Usage:

    use function Termwind\{render, setColors};
    
    setColors([
        'blue-300' => '#0133dc',
        'badass' => '#bada55',
    ]);
    
    render(<<<'HTML'
        <div class="my-1">
            <div class="bg-blue-300">
                Termwind now supports <b>`setColors()`</b>
            </div>
            <div class="mt-1 bg-badass text-black">
                Can be used like this: <b>`setColors(['badass' => '#bada55'])`</b>
            </div>
        </div>
    HTML);
    
    opened by xiCO2k 12
  • feat: adds `live` function to create dynamic console applications

    feat: adds `live` function to create dynamic console applications

    This pull request allows to make a particular section of the console dynamic. Here is an example:

    use function Termwind\{live};
    
    live(function () {
        static $counter = 0;
    
        $counter++;
    
        return '<div class="m-1">
            <span class="pl-1 pr-2 bg-blue-300">My counter</span>
            <span class="ml-1">' . $counter . '</span>
        </div>';
    })->refreshEvery(seconds: 1);
    

    Will render the following: live

    In addition, you may control when the refresh should stop, by calling the RefreshEvent::stop method.

    live(function (RefreshEvent $event) {
        return $event->stop();
    })->refreshEvery(seconds: 1);
    

    Finally, if you wish to control, when to render, clear, or refresh, you may control the flow using these methods:

    use function Termwind\{live};
    
    $live = live(fn () => 'html');
    
    $live->render(); // Re-runs the given closure, and renders its output.
    $live->clear(); // Removes all previous rendered html.
    $live->refresh(); // Refreshes the previous rendered html.
    $live->refreshEvery($seconds); // Refreshes the previous rendered html, every X amount of seconds.
    
    opened by nunomaduro 11
  • Added code element with code highlighter.

    Added code element with code highlighter.

    I decided not to use code from nunomaduro/collision package and copied Code Highlighter with some modifications.

    1. I got rid of ConsoleColor class and used css classes for syntax highlighting
    2. Replaced $linesBefore, $linesAfter with $startLine
    <code line="20" start-line="14">
        &lt;?php
    
        /** @test */
        function sentryReport()
        {
            try {
                throw new \Exception('Something went wrong');
            } catch (\Throwable $e) {
                report($e);
            }
        }
    </code>
    

    !!! Users have to convert all applicable characters to HTML entities inside code element !!!

    Will render

    image

    fixes #82

    opened by butschster 10
  • Add a `div` to render Inline type components

    Add a `div` to render Inline type components

    After checking on possible features to add, figured that would be awesome to have the capability to style multiple parts of the same span like its possible to do in HTML with multiple <span> inside of each other.

    From this code:

    
    use function Termwind\{span,a};
    
    span([
        span('Termind', 'ml-3 px-1 font-bold text-color-white bg-red'),
        span('it\'s like Tailwind CSS, but for the PHP command-line applications.', 'px-1'),
        a('Check it out on GitHub', 'mr-3 text-color-blue')->href('https://github.com/nunomaduro/termwind'),
    ])->render();
    
    

    Output

    image

    There is some edge cases still need to be handle. but want to know what do you think about this.

    opened by xiCO2k 10
  • Color is not applied on windows terminal with wsl.

    Color is not applied on windows terminal with wsl.

    Default colors are not being applied to html element on windows terminal (using windows sub system for linux). Also the parser trying to parse special characters as html, in this case <== gives an warning.

    require __DIR__ . '/vendor/autoload.php';
    
    use function Termwind\{render};
    
    // single line html...
    render('<div class="p-1 bg-green-300">Termwind</div><span class="text-red-200"><== this was supposed to be green.<span>');
    

    Output

    image

    opened by opuu 9
  • If there is an `\e` modifier inside a `<bg=#bada55>` it closes the background color

    If there is an `\e` modifier inside a `` it closes the background color

    Code:

    render(<<<'HTML'
        <div class="my-1 ml-3 px-2 bg-green-300 text-black">
            🍃 Termwind now have the capability to <b>extend</b> colors!
        </div>
    HTML);
    

    Result:

    image

    Posible Solution:

    • Change <bg> to and \e code
    • Or, find if there is any way to only remove the escape code added from <b>.
    bug 
    opened by xiCO2k 9
  • Gets rid of default tags <bg=default;options=> from console output

    Gets rid of default tags from console output

    One of the reason I decided to get rid of default tags is in this example

    <div class="bg-red">Hello <strong>world></div>
    

    When it parsed it looks like

    <bg=red;options=>Hello <bg=default;options=bold>world</></>
    

    As you noticed the word world has default background because of bg=default instead of red background.

    There are a lot of unnecessary style tags in output :)

    <br/> => <bg=default;options=></>\n
    <a>link text</a> => <bg=default;options=>link text</>
    <ol><li>list text 1</li></ol> => <bg=default;options=><bg=default;options=>1. list text 1</></>
    
    opened by butschster 9
  • Add display `block` Method

    Add display `block` Method

    This pull request will fix #58 and add a new display: block option to add to any component.

    Also by default div, ul and li elements will have block as default.

    opened by xiCO2k 7
  • Add text decoration hidden method

    Add text decoration hidden method

    This PR adds hidden method for text decoration. It will make the text invisible when applied.

    span('i am invisible with blue background color', 'hidden bg-blue')->render();
    

    I do not know if this will be useful or not, but it is part of ANSI Escape Codes. Also there are reverse, dim and blink which is not yet added to this package.

    Feel free to drop or accept this, cheers :beers:


    Apart from this PR, i also have some idea about this package:

    1. What if there is helper function called console which return the current renderer of termwind. It will be useful when we need the symfony console output directly.
    // print an error
    console()->writeln('<error>An error occured</error>');
    
    1. What if there is conditional rendering, using something like:
    span('i am on linux machine')->renderWhen(PHP_OS_FAMILY  == 'Linux');
    span('i am on macos machine')->renderWhen(PHP_OS_FAMILY  == 'Darwin');
    span('i am on windows machine')->renderWhen(PHP_OS_FAMILY  == 'Windows');
    
    1. Does this package going to achieve same goal as rich python package? link: https://github.com/willmcgugan/rich

    What do you think @nunomaduro ?

    opened by lakuapik 7
Releases(v1.15.0)
  • v1.15.0(Dec 20, 2022)

    What's Changed

    • [fix] Types by @fabio-ivona in https://github.com/nunomaduro/termwind/pull/158
    • [feat] autocomplete for questions by @fabio-ivona in https://github.com/nunomaduro/termwind/pull/153

    New Contributors

    • @fabio-ivona made their first contribution in https://github.com/nunomaduro/termwind/pull/158

    Full Changelog: https://github.com/nunomaduro/termwind/compare/v1.14.2...v1.15.0

    Source code(tar.gz)
    Source code(zip)
  • v1.14.2(Oct 28, 2022)

    What's Changed

    • feat: Allow to use SymfonyStyle ask method if exists. by @xiCO2k in https://github.com/nunomaduro/termwind/pull/156

    Full Changelog: https://github.com/nunomaduro/termwind/compare/v1.14.1...v1.14.2

    Source code(tar.gz)
    Source code(zip)
  • v1.14.1(Oct 17, 2022)

    What's Changed

    • Fix typos by @krsriq in https://github.com/nunomaduro/termwind/pull/152
    • fix: Truncate to work well with w-full or w-division. by @xiCO2k in https://github.com/nunomaduro/termwind/pull/155

    New Contributors

    • @krsriq made their first contribution in https://github.com/nunomaduro/termwind/pull/152

    Full Changelog: https://github.com/nunomaduro/termwind/compare/v1.14.0...v1.14.1

    Source code(tar.gz)
    Source code(zip)
  • v1.14.0(Aug 1, 2022)

    What's Changed

    • feat: Add support for w-auto. by @xiCO2k in https://github.com/nunomaduro/termwind/pull/148
    • Remove 'orange' color by @AdamGaskins in https://github.com/nunomaduro/termwind/pull/146
    • Add full ANSI color support by @AdamGaskins in https://github.com/nunomaduro/termwind/pull/147
    • Fixes bug when using truncate with paddings by @xiCO2k in https://github.com/nunomaduro/termwind/pull/149

    New Contributors

    • @AdamGaskins made their first contribution in https://github.com/nunomaduro/termwind/pull/146

    Full Changelog: https://github.com/nunomaduro/termwind/compare/v1.13.0...v1.14.0

    Source code(tar.gz)
    Source code(zip)
  • v1.13.0(Jul 1, 2022)

    What's Changed

    • fix: flex-1 with over COLUMN size content. by @xiCO2k in https://github.com/nunomaduro/termwind/pull/142
    • feat: Add min-w-{width} class. by @xiCO2k in https://github.com/nunomaduro/termwind/pull/143

    Full Changelog: https://github.com/nunomaduro/termwind/compare/v1.12.0...v1.13.0

    Source code(tar.gz)
    Source code(zip)
  • v1.12.0(Jun 27, 2022)

  • v1.11.1(Jun 17, 2022)

    Fixed

    • truncate only truncates text and not the styling by @xiCO2k in (https://github.com/nunomaduro/termwind/commit/840a9e9d8809603f11d19fe5336270eb96a8d3a8)

    Full Changelog: https://github.com/nunomaduro/termwind/compare/v1.11.0...v1.11.1

    Source code(tar.gz)
    Source code(zip)
  • v1.11.0(Jun 17, 2022)

    What's Changed

    • feat: Allow truncate to be used without params. by @xiCO2k in https://github.com/nunomaduro/termwind/pull/139

    Full Changelog: https://github.com/nunomaduro/termwind/compare/v1.10.1...v1.11.0

    Source code(tar.gz)
    Source code(zip)
  • v1.10.1(May 12, 2022)

  • v1.10.0(May 11, 2022)

    What's Changed

    • feat: Add flex and flex-1 classes. by @xiCO2k in https://github.com/nunomaduro/termwind/pull/137
    • Add .content-repeat class by @xiCO2k in https://github.com/nunomaduro/termwind/pull/138

    Full Changelog: https://github.com/nunomaduro/termwind/compare/v1.9.0...v1.10.0

    Source code(tar.gz)
    Source code(zip)
  • v1.9.0(May 3, 2022)

    Added

    • Add hidden class by @xiCO2k in https://github.com/nunomaduro/termwind/pull/134
    • Add justify-center class by @xiCO2k in https://github.com/nunomaduro/termwind/pull/135

    Fixed

    • Fixed justify-* round calculations by @xiCO2k in https://github.com/nunomaduro/termwind/pull/136
    • Fixed <br> with classes in eb2132f
    • Fixed inheritance issues on justify-* classes d050cba

    Full Changelog: https://github.com/nunomaduro/termwind/compare/v1.8.0...v1.9.0

    Source code(tar.gz)
    Source code(zip)
  • v1.8.0(Apr 22, 2022)

    What's Changed

    • Feet: Add justify-around and justify-evenly classes by @xiCO2k in https://github.com/nunomaduro/termwind/pull/133

    Full Changelog: https://github.com/nunomaduro/termwind/compare/v1.7.0...v1.8.0

    Source code(tar.gz)
    Source code(zip)
  • v1.7.0(Mar 30, 2022)

    What's Changed

    • fix: <hr /> width not respecting parent width. by @xiCO2k in https://github.com/nunomaduro/termwind/pull/130
    • feat: Add justify-between class. by @xiCO2k in https://github.com/nunomaduro/termwind/pull/129

    Full Changelog: https://github.com/nunomaduro/termwind/compare/v1.6.2...v1.7.0

    Source code(tar.gz)
    Source code(zip)
  • v1.6.2(Mar 18, 2022)

    What's Changed

    • fix: Fixes support for HTML tags on TableCells by @xiCO2k in https://github.com/nunomaduro/termwind/pull/128

    Full Changelog: https://github.com/nunomaduro/termwind/compare/v1.6.1...v1.6.2

    Source code(tar.gz)
    Source code(zip)
  • v1.6.1(Mar 17, 2022)

  • v1.6.0(Feb 24, 2022)

    What's Changed

    • Fix typo by @marcreichel in https://github.com/nunomaduro/termwind/pull/125
    • feat: Upgrade PHPStan to v1.0. by @xiCO2k in https://github.com/nunomaduro/termwind/pull/127
    • feat: Add MediaQuery Support. by @xiCO2k in https://github.com/nunomaduro/termwind/pull/126

    Full Changelog: https://github.com/nunomaduro/termwind/compare/v1.5.0...v1.6.0

    Source code(tar.gz)
    Source code(zip)
  • v1.5.0(Feb 14, 2022)

    What's Changed

    • Adds Laravel TermwindServiceProvider by @xiCO2k in https://github.com/nunomaduro/termwind/pull/123

    Full Changelog: https://github.com/nunomaduro/termwind/compare/v1.4.3...v1.5.0

    Source code(tar.gz)
    Source code(zip)
  • v1.4.3(Feb 3, 2022)

    What's Changed

    • fix: Fixes bug having multiple margins while using width with my by @xiCO2k in https://github.com/nunomaduro/termwind/pull/120

    Full Changelog: https://github.com/nunomaduro/termwind/compare/v1.4.2...v1.4.3

    Source code(tar.gz)
    Source code(zip)
  • v1.4.2(Jan 29, 2022)

    What's Changed

    • fix: max-wwith w-{fraction} childs. by @xiCO2k in https://github.com/nunomaduro/termwind/pull/118

    Full Changelog: https://github.com/nunomaduro/termwind/compare/v1.4.1...v1.4.2

    Source code(tar.gz)
    Source code(zip)
  • v1.4.1(Jan 29, 2022)

    What's Changed

    • Fixed <href> with more width that the parent element by @xiCO2k in https://github.com/nunomaduro/termwind/pull/117

    Full Changelog: https://github.com/nunomaduro/termwind/compare/v1.4.0...v1.4.1

    Source code(tar.gz)
    Source code(zip)
  • v1.4.0(Jan 26, 2022)

    What's Changed

    • feat: Add support for space-y and space-x by @xiCO2k in https://github.com/nunomaduro/termwind/pull/115

    Full Changelog: https://github.com/nunomaduro/termwind/compare/v1.3.0...v1.4.0

    Source code(tar.gz)
    Source code(zip)
  • v1.3.0(Jan 12, 2022)

    What's Changed

    • feat: Adds ask() method. by @xiCO2k in https://github.com/nunomaduro/termwind/pull/112
    • feat: Add max-w-{width} class. by @xiCO2k in https://github.com/nunomaduro/termwind/pull/111
    • feat: Add support for py, pt and pb. by @xiCO2k in https://github.com/nunomaduro/termwind/pull/113

    Full Changelog: https://github.com/nunomaduro/termwind/compare/v1.2.0...v1.3.0

    Source code(tar.gz)
    Source code(zip)
  • v1.2.0(Dec 16, 2021)

    What's Changed

    • Fix typo in README.md by @marcreichel in https://github.com/nunomaduro/termwind/pull/106
    • feat: Add terminal()->clear() method. by @xiCO2k in https://github.com/nunomaduro/termwind/pull/107
    • Fix function_exists() checks by @mabar in https://github.com/nunomaduro/termwind/pull/108
    • Added support for HTML5 tags by @opuu in https://github.com/nunomaduro/termwind/pull/110
    • Fix bug when using emojis with w-full. (f2f426)

    New Contributors

    • @marcreichel made their first contribution in https://github.com/nunomaduro/termwind/pull/106
    • @mabar made their first contribution in https://github.com/nunomaduro/termwind/pull/108
    • @opuu made their first contribution in https://github.com/nunomaduro/termwind/pull/110

    Full Changelog: https://github.com/nunomaduro/termwind/compare/v1.1.0...v1.2.0

    Source code(tar.gz)
    Source code(zip)
  • v1.1.0(Dec 6, 2021)

  • v1.0.0(Dec 2, 2021)

Owner
Nuno Maduro
Software engineer at @laravel — working on Laravel, Forge, and Vapor. Created @pestphp, @laravel-zero, collision, larastan, php insights, and more.
Nuno Maduro
Display your Laravel routes in the console, but make it pretty. 😎

Pretty Routes for Laravel Display your Laravel routes in the console, but make it pretty. ?? Installation You can install the package via composer: co

Alex 630 Dec 30, 2022
Console - The Console component eases the creation of beautiful and testable command line interfaces.

Console Component The Console component eases the creation of beautiful and testable command line interfaces. Sponsor The Console component for Symfon

Symfony 9.4k Jan 7, 2023
A CLI tool to check whether a specific composer package uses imported symbols that aren't part of its direct composer dependencies

A CLI tool to analyze composer dependencies and verify that no unknown symbols are used in the sources of a package. This will prevent you from using "soft" dependencies that are not defined within your composer.json require section.

Matthias Glaub 722 Dec 30, 2022
Simple but yet powerful library for running almost all artisan commands.

:artisan gui Simple but yet powerful library for running some artisan commands. Requirements Laravel 8.* php ^7.3 Installation Just install package: c

null 324 Dec 28, 2022
The Hoa\Console library.

Hoa is a modular, extensible and structured set of PHP libraries. Moreover, Hoa aims at being a bridge between industrial and research worlds. Hoa\Con

Hoa 366 Dec 14, 2022
ReactPHP Shell, based on the Symfony Console component.

Pecan Event-driven, non-blocking shell for ReactPHP. Pecan (/pɪˈkɑːn/) provides a non-blocking alternative to the shell provided in the Symfony Consol

Michael Crumm 43 Sep 4, 2022
Customized loading ⌛ spinner for Laravel Artisan Console.

Laravel Console Spinner Laravel Console Spinner was created by Rahul Dey. It is just a custom Progress Bar inspired by icanhazstring/symfony-console-s

Rahul Dey 71 Oct 26, 2022
Supercharge your Symfony console commands!

zenstruck/console-extra A modular set of features to reduce configuration boilerplate for your commands: /** * Creates a user in the database. * *

Kevin Bond 29 Nov 19, 2022
🤖 GitHub Action to run symfony console commands.

Symfony Console GitHub Action Usage You can use it as a Github Action like this: # .github/workflows/lint.yml name: "Lint" on: pull_request: push

Nucleos 3 Oct 20, 2022
Laravel Console Toolkit

This Package provides some usefully console features like the attribute syntax for arguments and options, validation, auto ask and casting.

Tobi 29 Nov 29, 2022
Console component from Zend Framework

zend-console Repository abandoned 2019-12-31 This repository has moved to laminas/laminas-console. Zend\Console is a component to design and implement

Zend Framework 47 Mar 16, 2021
Simple and customizable console log output for CLI apps.

Console Pretty Print Simple and customizable console log output for CLI apps. Highlights Simple installation (Instalação simples) Very easy to customi

William Alvares 3 Aug 1, 2022
A PHP Command Line tool that makes it easy to compile, concat, and minify front-end Javascript and CSS/SCSS dependencies.

Front End Compiler A PHP Command Line tool that makes it easy to compile, concat, and minify front-end Javascript and CSS/SCSS dependencies. The minif

Happy Medium 2 Nov 12, 2021
A CLI program that helps you check your endpoints by requesting the given servers and send a report message in any supported channel like Telegram

API Monitor A CLI program that help you check your endpoints by requesting the given servers and send a report message in any supported channel ( Tele

Hussein Feras 51 Aug 21, 2022
I gues i tried to make a shell that's looks like a terminal in single php file

php-shell-gui Terms of service This tool can only be used for legal purposes. You take full responsibility for any actions performed using this. The o

Squar3 4 Aug 23, 2022
Tailwind UI is a Tailwind CSS component library designed by the authors of Tailwind CSS

Tailwind UI is a Tailwind CSS component library designed by the authors of Tailwind CSS. This is a Winter CMS plugin that provides a custom, TailwindUI-based skin for the backend.

Winter CMS 9 Dec 19, 2022
🍃 In short, it's like Tailwind CSS, but for the PHP command-line applications.

Termwind Termwind allows you to build unique and beautiful PHP command-line applications, using the Tailwind CSS API. In short, it's like Tailwind CSS

Nuno Maduro 1.8k Dec 30, 2022
This package provides a console command to convert dynamic JS/CSS to static JS/CSS assets.

Laravel Nova Search This package provides a console command to convert dynamic JS/CSS to static JS/CSS assets. Requirements laravel-mix v6.0+ php 7.3+

Akki Khare 3 Jul 19, 2022
🔌 Convert Bootstrap CSS code to Tailwind CSS code

Tailwindo This tool can convert Your CSS framework (currently Bootstrap) classes in HTML/PHP (any of your choice) files to equivalent Tailwind CSS cla

Awssat 938 Dec 24, 2022