Skip to content

district09/php_package_command-builder

Repository files navigation

Command builder

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'; }; }

About

A generic shell command builder.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages