first version of phar cli interface; currently lists files only
This commit is contained in:
parent
afe1fbd4b4
commit
75156bfd20
@ -314,12 +314,9 @@
|
||||
<echo msg="Creating .phar for SemanticScuttle ${version}"/>
|
||||
<delete file="${pharfilepath}" quiet="yes"/>
|
||||
<pharpackage basedir="." destfile="${pharfilepath}"
|
||||
alias="sc.phar"
|
||||
stub="res/phar-stub.php">
|
||||
<!--
|
||||
webstub="www/index.php"
|
||||
clistub="www/index.php"
|
||||
-->
|
||||
alias="SemanticScuttle.phar"
|
||||
stub="res/phar-stub.php"
|
||||
>
|
||||
<metadata>
|
||||
<element name="version" value="${version}" />
|
||||
<element name="authors">
|
||||
|
@ -6,6 +6,14 @@ if (!in_array('phar', stream_get_wrappers())
|
||||
exit;
|
||||
}
|
||||
|
||||
Phar::interceptFileFuncs();
|
||||
|
||||
if (php_sapi_name() == 'cli') {
|
||||
require_once dirname(__FILE__) . '/../src/SemanticScuttle/Phar/Cli.php';
|
||||
$cli = new SemanticScuttle_Phar_Cli();
|
||||
$cli->run();
|
||||
exit;
|
||||
}
|
||||
|
||||
function mapUrls($path)
|
||||
{
|
||||
@ -19,7 +27,6 @@ function mapUrls($path)
|
||||
return '/www' . $path;
|
||||
}
|
||||
|
||||
Phar::interceptFileFuncs();
|
||||
Phar::webPhar(
|
||||
null,
|
||||
'www/index.php',
|
||||
|
81
src/SemanticScuttle/Phar/Cli.php
Normal file
81
src/SemanticScuttle/Phar/Cli.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* SemanticScuttle - your social bookmark manager.
|
||||
*
|
||||
* PHP version 5.
|
||||
*
|
||||
* @category Bookmarking
|
||||
* @package SemanticScuttle
|
||||
* @author Christian Weiske <cweiske@cweiske.de>
|
||||
* @license AGPL http://www.gnu.org/licenses/agpl.html
|
||||
* @link http://sourceforge.net/projects/semanticscuttle
|
||||
*/
|
||||
|
||||
/**
|
||||
* Command line interface for the SemanticScuttle.phar file.
|
||||
* Can be used to extract parts of the phar file and to run
|
||||
* scripts in it.
|
||||
*
|
||||
* @category Bookmarking
|
||||
* @package SemanticScuttle
|
||||
* @author Christian Weiske <cweiske@cweiske.de>
|
||||
* @license AGPL http://www.gnu.org/licenses/agpl.html
|
||||
* @link http://sourceforge.net/projects/semanticscuttle
|
||||
*/
|
||||
class SemanticScuttle_Phar_Cli
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$this->listAction();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Lists the contents of this phar archive and echos the output
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function listAction()
|
||||
{
|
||||
$excludes = array(
|
||||
'data/locales',
|
||||
'data/templates',
|
||||
'src',
|
||||
'www',
|
||||
);
|
||||
$it = new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator(
|
||||
'phar://SemanticScuttle.phar/'
|
||||
)
|
||||
);
|
||||
while($it->valid()) {
|
||||
if (!$it->isDot()) {
|
||||
$name = $it->getSubPathName();
|
||||
$excluded = false;
|
||||
foreach ($excludes as $exclude) {
|
||||
if (substr($name, 0, strlen($exclude)) == $exclude) {
|
||||
$excluded = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$excluded) {
|
||||
echo $name . "\n";
|
||||
}
|
||||
}
|
||||
$it->next();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function runAction()
|
||||
{
|
||||
//FIXME
|
||||
}
|
||||
|
||||
|
||||
public function extractAction()
|
||||
{
|
||||
//FIXME
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue
Block a user