digipolisgent/command-builder

A generic shell command builder.

1.2.1 2019-07-08 08:50 UTC

This package is auto-updated.

Last update: 2024-11-07 15:21:04 UTC


README

Code example

<?php

require_once 'vendor/autoload.php';

use DigipolisGent\CommandBuilder\CommandBuilder;

$builder = CommandBuilder::create('ls')
        ->addFlag('a')
        ->addFlag('l')
    ->pipeOutputTo('grep')
        ->addArgument('mydir')
    ->onSuccess('echo')
        ->addArgument('mydir already exists')
    ->onFailure(
        CommandBuilder::create('mkdir')
            ->addArgument('mydir')
        ->onSuccess('echo')
            ->addArgument('mydir created')
      );
print $builder;

Output

{ { { ls -a -l | grep 'mydir'; } && echo 'mydir already exists'; } || { mkdir 'mydir' && echo 'mydir created'; }; }