https://github.com/chipslays/clify
📟 Developing CLI applications in PHP.
https://github.com/chipslays/clify
cli cli-utilities php-cli-library
Last synced: 3 months ago
JSON representation
📟 Developing CLI applications in PHP.
- Host: GitHub
- URL: https://github.com/chipslays/clify
- Owner: chipslays
- Created: 2021-01-14T15:45:47.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-03-10T11:17:49.000Z (almost 5 years ago)
- Last Synced: 2025-01-03T04:52:30.117Z (about 1 year ago)
- Topics: cli, cli-utilities, php-cli-library
- Language: PHP
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# WIP: 📟 Clify
Developing CLI applications in PHP.
## Installation
```bash
$ composer require chipslays/clify
```
## Usage
Place this code in `app` file:
```php
#!/usr/bin/env php
getArgs()->toArray());
```
Run `app` file in Terminal:
```bash
$ php app --data "hello world" --save "./path/to/file.txt" -o --append -val="test" --some="spaces here" lonely
```
Terminal output:
```php
Array
(
[data] => hello world
[save] => ./path/to/file.txt
[o] => 1
[append] => 1
[val] => test
[some] => spaces here
[lonely] => 1
)
```
```php
use Clify\Cli;
require 'vendor/autoload.php';
out('text');
error('text');
success('text');
info('text');
warning('text');
$cli->get('some_arg', 'default value');
```
Terminal output (with new line):
```php
use Clify\Cli;
require 'vendor/autoload.php';
echo Cli::out("{blue}Blue text");
```
Colorize text output:
```php
use Clify\Cli;
require 'vendor/autoload.php';
echo Cli::colorize("{blue}Blue text{reset}");
echo Cli::colorize("{black}{bg:yellow} Black text on Yellow background{reset}");
// At the end, it will automatically add {reset}
echo Cli::colorizeLine("{blue}Blue text");
```
Available colors:
```php
$list = [
"{reset}" => "\e[0m",
"{black}" => "\e[0;30m",
"{white}" => "\e[1;37m",
"{dark_grey}" => "\e[1;30m",
"{dark_gray}" => "\e[1;30m",
"{light_grey}" => "\e[0;37m",
"{light_gray}" => "\e[0;37m",
"{red}" => "\e[0;31m",
"{light_red}" => "\e[1;31m",
"{green}" => "\e[0;32m",
"{light_green}" => "\e[1;32m",
"{brown}" => "\e[0;33m",
"{yellow}" => "\e[1;33m",
"{blue}" => "\e[0;34m",
"{magenta}" => "\e[0;35m",
"{light_magenta}" => "\e[1;35m",
"{cyan}" => "\e[0;36m",
"{light_cyan}" => "\e[1;36m",
"{bg:black}" => "\e[40m",
"{bg:red}" => "\e[41m",
"{bg:green}" => "\e[42m",
"{bg:yellow}" => "\e[43m",
"{bg:blue}" => "\e[44m",
"{bg:magenta}" => "\e[45m",
"{bg:cyan}" => "\e[46m",
"{bg:light_grey}" => "\e[47m",
"{bg:light_gray}" => "\e[47m",
];
```