コード例 #1
0
ファイル: application.php プロジェクト: noccy80/cherryphp
 function createapp($template = null, $appns = null)
 {
     $con = \Cherry\Cli\Console::getAdapter();
     if (!$appns) {
         printf("Use: create <template> <appns>\n");
         return 1;
     }
     $args = func_get_args();
     $opts = $this->parseOpts(array_slice($args, 2), array('replace' => '+replace'));
     if (empty($opts['replace'])) {
         $opts['replace'] = false;
     }
     $con->write("Creating new project %s...\n", $appns);
     $tpath = CHERRY_LIB . '/share/projects/' . $template . '/';
     $rdi = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($tpath, \FilesystemIterator::SKIP_DOTS));
     foreach ($rdi as $file) {
         if (strpos((string) $file, 'PKG-META') !== false) {
             $sub = explode(DIRECTORY_SEPARATOR, substr($file, strpos((string) $file, 'PKG-META') + 9));
             if ($sub[0] == 'triggers') {
                 require $file;
             }
         } else {
             $dest = str_replace($tpath, './', $file);
             // Check paths
             $path = dirname($dest);
             if (!file_exists($path)) {
                 mkdir($path, 0777, true);
             }
             // Copy file
             copy($file, $dest);
         }
     }
     \Cherry\Base\Event::invoke('cherryutil.application.post-setup', array('approot' => \getcwd(), 'appns' => $appns, 'replace' => $opts['replace']), $con);
     $con->write("Done\n");
 }
コード例 #2
0
ファイル: sysinfo.php プロジェクト: noccy80/cherryphp
 function phpdefines()
 {
     $args = func_get_args();
     $opts = $this->parseOpts($args, array('like' => 'like:'));
     $con = \cherry\cli\Console::getAdapter();
     $defs = \get_defined_constants();
     foreach ($defs as $k => $v) {
         if (empty($opts['like']) || fnmatch($opts['like'], $k, \FNM_CASEFOLD)) {
             $con->write("%s => %s\n", $k, $v);
         }
     }
 }
コード例 #3
0
ファイル: install.php プロジェクト: noccy80/cherryphp
 function installTools()
 {
     $con = \cherry\cli\Console::getAdapter();
     $foh = new \cherryutil\FileOps();
     $foh->setReplace(true);
     $home = getenv('HOME');
     $bindir = $home . '/bin';
     $con->write("Installing tools...\n");
     $tools = array('cherrydoc', 'cherry', 'cherryview', 'cherrykey', 'editserialize', 'cherryprofiler', 'sdlint');
     foreach ($tools as $tool) {
         $foh->install(CHERRY_LIB . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . $tool, $bindir . DIRECTORY_SEPARATOR . $tool, 0777);
     }
     $con->write("Done\n");
 }
コード例 #4
0
ファイル: keystorefile.php プロジェクト: noccy80/cherryphp
 public function __construct($store, $key = null, $crypto = 'tripledes')
 {
     if ($key == true) {
         $ca = \Cherry\Cli\Console::getAdapter();
         $key = $ca->readpass("Password for keystore " . basename($store) . ": ");
     }
     if (!$key) {
         $key = 0.0;
     }
     $this->key = $this->deriveKey($key);
     if (file_exists($store)) {
         debug("KeyStore: Opening %s", $store);
         $buf = file_get_contents($store);
         $buf = Crypto::tripledes($this->key)->decrypt($buf);
         $buf = gzuncompress($buf);
         if (!$buf) {
             $this->lasterror = self::ERR_KEYSTORE_ERROR;
             $this->keys = [];
         } else {
             $this->keys = @unserialize($buf);
         }
     }
     $this->store = $store;
 }
コード例 #5
0
ファイル: ansi.php プロジェクト: noccy80/cherryphp
#!/usr/bin/php
<?php 
require_once __DIR__ . "/../../share/include/cherryphp";
use Cherry\Cli\Ansi;
$ca = \Cherry\Cli\Console::getAdapter();
$ca->write(Ansi::pushColor(\Ansi\Color::RED, \Ansi\Color::YELLOW) . "This should be red on yellow and span the entire line" . Ansi::clearToEnd() . Ansi::popColor() . "\n" . "And this should be normal text again.\n" . "There is also " . Ansi::setBold() . "bold" . Ansi::clearBold() . ", " . Ansi::setUnderline() . "underline" . Ansi::clearUnderline() . " and " . Ansi::setReverse() . "reverse" . Ansi::clearReverse() . " text available.\n" . "And take a look at these color bars, pure 256-color ANSI.\n");
for ($m = 0; $m < 32; $m++) {
    $ca->write(\Ansi\Color::color256(null, $m * 8 . ',' . $m * 8 . ',' . $m * 8) . "  ");
}
$ca->write(Ansi::reset() . "\n");
for ($m = 0; $m < 32; $m++) {
    $ca->write(\Ansi\Color::color256(null, '0,' . $m * 8 . ',0') . "  ");
}
$ca->write(Ansi::reset() . "\n");
for ($m = 0; $m < 32; $m++) {
    $ca->write(\Ansi\Color::color256(null, '0,0,' . $m * 8) . "  ");
}
$ca->write(Ansi::reset() . "\n");
for ($m = 0; $m < 32; $m++) {
    $ca->write(\Ansi\Color::color256(null, $m * 8 . ',0,0') . "  ");
}
$ca->write(Ansi::reset() . "\n");
$ca->write(Ansi::color("This is a line in green.\n", "green"));
$ca->write(Ansi::color("And a line in red.\n", "red"));
コード例 #6
0
ファイル: repository.php プロジェクト: noccy80/cherryphp
 function __construct($url, RepositoryList $repolist)
 {
     $this->con = \Cherry\Cli\Console::getAdapter();
     $this->url = $url;
     $this->rl = $repolist;
 }
コード例 #7
0
ファイル: fileops.php プロジェクト: noccy80/cherryphp
 public function __construct()
 {
     $this->con = \cherry\cli\Console::getAdapter();
 }
コード例 #8
0
ファイル: package.php プロジェクト: noccy80/cherryphp
 function packageinfo($package = null)
 {
     $con = \cherry\cli\Console::getAdapter();
     if (!$package) {
         $con->warn("No package specified.\n");
         return 1;
     }
     $fh = @fopen('phar://' . $package . '/manifest.json', 'r');
     if (!$fh) {
         $con->write("Not a valid cherry package: %s\n", $package);
         return 1;
     }
     $data = json_decode(fread($fh, 65535));
     $con->write("Package: %s %s\n", $data->name, $data->version);
     $con->write("Type: %s\n", $data->type);
     $phar = new \Phar($package);
     foreach (new \RecursiveIteratorIterator($phar) as $file) {
         printf("%s (%d bytes)\n", $file, $file->getSize());
     }
 }
コード例 #9
0
 public function write($str)
 {
     static $con;
     if (!$con) {
         $con = Console::getAdapter();
     }
     $args = func_get_args();
     call_user_func_array([$con, 'write'], $args);
     parent::write(call_user_func_array('sprintf', $args));
 }