Initial commit of new codebase
This commit is contained in:
65
src/MakePhar/Application.php
Normal file
65
src/MakePhar/Application.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace MakePhar;
|
||||
|
||||
class Application
|
||||
{
|
||||
|
||||
protected $config;
|
||||
|
||||
private function parseCommandLine()
|
||||
{
|
||||
$opts = "h";
|
||||
$long = [ 'help' ];
|
||||
|
||||
$parsed = getopt($opts, $long);
|
||||
$config = [
|
||||
'help' => false,
|
||||
'manifest' => getcwd()."/makephar.sdl",
|
||||
'output' => null,
|
||||
'compress' => false,
|
||||
];
|
||||
|
||||
foreach ($parsed as $k=>$v) switch ($k) {
|
||||
case 'h':
|
||||
case 'help':
|
||||
$config['help'] = true;
|
||||
break;
|
||||
}
|
||||
|
||||
$this->config = (object)$config;
|
||||
}
|
||||
|
||||
private function printHelp()
|
||||
{
|
||||
printf("Usage: makephar [opts]\n");
|
||||
printf("Options: -h,--help Show this help\n");
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
$this->parseCommandLine();
|
||||
|
||||
if ($this->config->help) {
|
||||
$this->printHelp();
|
||||
return;
|
||||
}
|
||||
|
||||
$this->buildManifest();
|
||||
}
|
||||
|
||||
protected function buildManifest()
|
||||
{
|
||||
$manifests = Manifest::createFromFile($this->config->manifest);
|
||||
|
||||
foreach ($manifests as $manifest) {
|
||||
log_info("Building %s", $manifest->getOutput());
|
||||
$builder = new PharBuilder($manifest);
|
||||
$builder->prepare();
|
||||
$builder->build();
|
||||
$builder->finalize();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user