コード例 #1
0
ファイル: main.php プロジェクト: datagit/shellwrap
 public function testLsAgainstGlob()
 {
     $output = sh::ls();
     // @TODO: Need to figure out a nicer way of doing this
     // Needs to be an object for the piping, but then gets converted to a string
     // when __toString is fired.
     $output = trim(strval($output));
     $output = explode("\n", $output);
     $glob_output = glob('*');
     $this->assertEquals($glob_output, $output);
 }
コード例 #2
0
ファイル: example.php プロジェクト: datagit/shellwrap
#!/usr/bin/env php
<?php 
require_once __DIR__ . '/../vendor/autoload.php';
use MrRio\ShellWrap as sh;
// List all files in current dir
echo sh::ls();
// Touch a file to create it
sh::touch('file.html');
// Remove file
sh::rm('file.html');
// Remove file again (this fails, and throws an exception because the file doesn't exist)
try {
    sh::rm('file.html');
} catch (Exception $e) {
    echo 'Caught failing sh::rm() call';
}
// Checkout a branch in git
sh::git('checkout', 'master');
// You can also pipe the output of one command, into another
// This downloads example.com through cURL, follows location, then pipes through grep to
// filter for 'html'
echo sh::grep('html', sh::curl('http://example.com', array('location' => true)));
// This throws an exception, as 'invalidoption' is not a valid argument
try {
    echo sh::ls(array('invalidoption' => true));
} catch (Exception $e) {
    echo 'Caught failing sh::ls() call';
}
コード例 #3
0
ファイル: ls.php プロジェクト: datagit/shellwrap
#!/usr/bin/env php
<?php 
require_once __DIR__ . '/../vendor/autoload.php';
use MrRio\ShellWrap as sh;
echo sh::ls();