diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..cd8eb86 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +; This file is for unifying the coding style for different editors and IDEs. +; More information at http://editorconfig.org + +root = true + +[*] +charset = utf-8 +indent_size = 4 +indent_style = space +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8dfd308 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,10 @@ +# Path-based git attributes +# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html + +/.editorconfig export-ignore +/.gitattributes export-ignore +/.github export-ignore +/.gitignore export-ignore +/art export-ignore +/phpunit.xml.dist export-ignore +/tests export-ignore diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 0000000..ed5409f --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,81 @@ +name: "run-tests" + +on: [push] + +jobs: + test: + runs-on: ubuntu-latest + + strategy: + fail-fast: true + matrix: + php: [7.2, 7.3, 7.4] + laravel: [5.7.*, 6.*, 7.*] + include: + - laravel: 7.* + testbench: 5.* + - laravel: 6.* + testbench: 4.* + - laravel: 5.7.* + testbench: 3.7.* + + name: PHP ${{ matrix.php }} / L ${{ matrix.laravel }} + + steps: + - name: Checkout code + uses: actions/checkout@v1 + + - name: Cache dependencies + uses: actions/cache@v1 + with: + path: ~/.composer/cache/files + key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: xdebug + + - name: Install dependencies + run: | + composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update + composer update --prefer-dist --no-interaction --no-suggest + + - name: Execute tests + run: vendor/bin/phpunit --coverage-clover clover.xml + + - name: Store coverage report + uses: actions/upload-artifact@v2 + with: + name: coverage-report + path: clover.xml + + coverage: + runs-on: ubuntu-latest + + needs: [test] + + name: Code coverage + + steps: + - name: Checkout code + uses: actions/checkout@v1 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 7.4 + coverage: none + + - name: Download coverage report + uses: actions/download-artifact@v2 + with: + name: coverage-report + + - name: Submit code coverage report + env: + COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + composer global require cedx/coveralls + coveralls clover.xml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3983a9f --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.DS_Store +.idea +.vscode +/vendor +composer.lock +composer.phar diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..23f3d31 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,9 @@ +The MIT License (MIT) + +Copyright (c) 2020, Wouter Peschier + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..cc1932c --- /dev/null +++ b/README.md @@ -0,0 +1,50 @@ +# Fancy Console for Laravel + +[![Author](http://img.shields.io/badge/by-@kielabokkie-lightgrey.svg?style=flat-square)](https://twitter.com/kielabokkie) +[![Packagist Version](https://img.shields.io/packagist/v/kielabokkie/laravel-fancy-console.svg?style=flat-square)](https://packagist.org/packages/kielabokkie/laravel-fancy-console) +[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md) + +Fancy Console for Laravel provides a `FancyConsole` trait that gives you a few extra fancy styled console outputs to compliment the already useful default Laravel ones. + +## Requirements + +* PHP >= 7.2 +* Laravel 5.8 and up + +## Installation + +Install the package via composer: + +```bash +composer require kielabokkie/laravel-fancy-console +``` + +## Usage + +Firstly you'll have to add the `FancyConsole` trait to your command: + +```php +success('Yes, it worked!'); + +$this->fail('Oh no, it did not work.'); + +$this->successBlock('This is a great success'); + +$this->errorBlock('This is a serious error'); +``` diff --git a/art/screenshot1.png b/art/screenshot1.png new file mode 100644 index 0000000..7142d3b Binary files /dev/null and b/art/screenshot1.png differ diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..38038dc --- /dev/null +++ b/composer.json @@ -0,0 +1,20 @@ +{ + "name": "kielabokkie/laravel-fancy-console", + "description": "A trait to give your console commands some extra fancy output", + "type": "library", + "license": "MIT", + "authors": [ + { + "name": "kielabokkie", + "email": "kielabokkie@gmail.com" + } + ], + "require": { + "php": "^7.1" + }, + "autoload": { + "psr-4": { + "Kielabokkie\\FancyConsole\\": "src" + } + } +} diff --git a/src/Traits/FancyConsole.php b/src/Traits/FancyConsole.php new file mode 100644 index 0000000..cf857b7 --- /dev/null +++ b/src/Traits/FancyConsole.php @@ -0,0 +1,50 @@ +info(' SUCCESS ' . $string); + } + + /** + * Fail line that gets prepended with a colourful FAIL. + * + * @param string $string + * @return string + */ + public function fail($string) + { + return $this->info(' FAIL ' . $string); + } + + /** + * A green success block that's nicely padded. + * + * @param string $string + * @return string + */ + public function successBlock($string) + { + return $this->output->success($string); + } + + /** + * A red error block that's nicely padded. + * + * @param string $string + * @return string + */ + public function errorBlock($string) + { + return $this->output->error($string); + } +}