예제 #1
0
파일: main.php 프로젝트: datagit/shellwrap
 public function testCurlCommand()
 {
     sh::curl('http://example.com/', array('output' => 'page.html', 'silent' => false, 'location' => true));
     // @TODO: Make this less horrible, save files in a temp dir
     $this->assertFileExists('page.html');
     sh::rm('page.html');
     $this->assertFileNotExists('page.html');
 }
예제 #2
0
파일: grep.php 프로젝트: datagit/shellwrap
#!/usr/bin/env php
<?php 
require_once __DIR__ . '/vendor/autoload.php';
use MrRio\ShellWrap as sh;
$sh = new sh();
try {
    $curl = $sh->curl('https://raw.github.com/guumaster/sh/master/README.md');
    $grep = $sh->grep('ASDFInstallation', $curl);
    echo "match\n";
    echo $grep;
} catch (Exception $e) {
    #echo $e->getMessage();
    #echo $e->getCode();
    echo "no match\n";
}
예제 #3
0
#!/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';
}
예제 #4
0
파일: ls.php 프로젝트: datagit/shellwrap
#!/usr/bin/env php
<?php 
require_once __DIR__ . '/../vendor/autoload.php';
use MrRio\ShellWrap as sh;
echo sh::ls();