Skip to content
This repository has been archived by the owner on Mar 30, 2020. It is now read-only.

mcuadros/cli-array-editor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CLIArrayEditor Build Status

This library provides an easy way to edit arrays in CLI using vim or your preferred editor.

Can be useful in scenarios where we need an interface to edit arrays from a CLI PHP application, CLIArrayEditor will open an editor with the array in a readable format (json, yaml, etc) and wait for the user (like "crontab -e" or "git commit").

The editor can be configured or by default $EDITOR from the environment will be used.

Requirements

  • PHP 5.3.23;
  • Unix system;
  • PECL yaml >= 0.5.0 (optional)

Installation

The recommended way to install CLIArrayEditor is through composer. You can see package information on Packagist.

{
    "require": {
        "mcuadros/cli-array-editor": "dev"
    }
}

Examples

use CLIArrayEditor\Editor;
use CLIArrayEditor\Format\JSON;

$tmp = array(
    'baz' => true,
    'foo' => 'bar'
);

$editor = new Editor();
$result = $editor
    ->setFormat(new JSON)
    ->edit($tmp);

print_r($result);

Check available Editor's methods in src/CLIArrayEditor/Editor.php

Tests

Tests are in the tests folder. To run them, you need PHPUnit. Example:

$ phpunit --configuration phpunit.xml.dist

License

MIT, see LICENSE

About

This class provides an easy way to edit arrays in CLI using vim or your preferred editor.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages