function help($command = null) { if (!$command) { //$app = \cherry\Lepton::getInstance()->getApplication(); $app = App::app(); $app->usage(); } else { $cobj = \cherryutil\CommandList::getInstance()->findCommand($command); printf("Command:\n %s - %s\n\n", $command, $cobj->getDescription()); printf("Synopsis:\n %s\n\n", $cobj->getSynopsis()); if ($help = $cobj->getHelp()) { printf("Description:\n"); $l = explode("\n", $help); foreach ($l as $line) { printf(" %s\n", $line); } } } }
$sdl->addChild($col); } // Convert the indexes to SDL $idx = new SdlTag("indexes"); foreach ($table->getIndexes() as $ix) { $cols = $ix->columns; $ii = new SdlTag($ix->type, $ix->name); $ii->setComment("Index {$ix->name}"); $ii->addChild(new SdlTag(NULL, $cols)); $idx->addChild($ii); } $sdl->addChild($idx); $rs = $conn->query("SELECT * FROM {$table->name}"); $data = new SdlTag("data"); foreach ($rs as $row) { $rdata = new SdlTag("row"); foreach ($row as $k => $v) { if (!is_integer($k)) { $rdata->addChild(new SdlTag($k, $v)); } } $data->addChild($rdata); } $sdl->addChild($data); echo $sdl->encode() . "\n"; } } } } CommandList::getInstance()->registerBundle(new DatabaseCommands());
$meta = parse_ini_file($fn, true); $ename = empty($meta['config']['name']) ? basename($fn, '.ini') : $meta['config']['name']; $eversion = empty($meta['config']['version']) ? '(Unknown version)' : $meta['config']['version']; printf(" %-16s %s %s\n", basename($fn, '.ini'), $ename, $eversion); } } } } class TemplateStrings { private $data = array(); public function __get($key) { if (array_key_exists($key, $this->data)) { return $this->data[$key]; } return sprintf('<%s>', $key); } public function __set($key, $value) { $this->data[$key] = $value; } public function __unset($key) { if (array_key_exists($key, $this->data)) { unset($this->data[$key]); } } } CommandList::getInstance()->registerBundle(new ApplicationCommands());
<?php namespace CherryUtil\commands; use cherryutil\Command; use cherryutil\CommandBundle; use cherryutil\CommandList; class MvcCommands extends CommandBundle { function getCommands() { return array(new Command('view', '<url>', 'Load the specified url via the MVC application and display the output', array($this, 'view'))); } function view($url = null) { } } CommandList::getInstance()->registerBundle(new MvcCommands());
if (is_object($val)) { $this->con->write($pre . "+ {$key}\n"); $this->dumpcfg($val, $r + 1); } elseif (is_array($val)) { $this->con->write($pre . "- {$key}\n"); $this->dumpcfg($val, $r + 1); } else { $this->con->write($pre . " {$key} = {$val}\n"); } } } function phpextensions() { $con = \cherry\cli\Console::getAdapter(); $con->putColumns(\get_loaded_extensions(), 25); } 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); } } } } CommandList::getInstance()->registerBundle(new SysInfoCommands());
<?php namespace CherryUtil\commands; use cherryutil\Command; use cherryutil\CommandBundle; use cherryutil\CommandList; class ScaffoldingCommands extends CommandBundle { function getCommands() { return array(); /*array( new Command('list-loaders','', 'List the available loaders.', array($this,'listloaders')), new Command('list-templates','', 'List the available application templates.', array($this,'listtemplates')), );*/ } } CommandList::getInstance()->registerBundle(new ScaffoldingCommands());
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()); } } function liststubs() { $loaderpath = CHERRY_LIB . '/share/stubs'; $it = new \FileSystemIterator($loaderpath, \FileSystemIterator::SKIP_DOTS); printf("Available stubs:\n"); foreach ($it as $loader) { $fn = $loader->__toString(); if (fnmatch('*.ini', $fn)) { $meta = parse_ini_file($fn, true); $ename = empty($meta['stub']['name']) ? basename($fn, '.ini') : $meta['stub']['name']; $eversion = empty($meta['stub']['version']) ? '(Unknown version)' : $meta['stub']['version']; printf(" %-16s %s %s\n", basename($fn, '.ini'), $ename, $eversion); } } } function deploy() { } } CommandList::getInstance()->registerBundle(new PackageCommands());