Added support for phar metadata
This commit is contained in:
@ -9,7 +9,7 @@ class Application
|
||||
|
||||
private function parseCommandLine()
|
||||
{
|
||||
$opts = "hn";
|
||||
$opts = "hnq";
|
||||
$long = [ 'help', 'new' ];
|
||||
|
||||
$parsed = getopt($opts, $long);
|
||||
@ -19,6 +19,7 @@ class Application
|
||||
'manifest' => getcwd()."/makephar.sdl",
|
||||
'output' => null,
|
||||
'compress' => false,
|
||||
'quiet' => false,
|
||||
];
|
||||
|
||||
foreach ($parsed as $k=>$v) switch ($k) {
|
||||
@ -30,6 +31,9 @@ class Application
|
||||
case 'new':
|
||||
$config['init'] = true;
|
||||
break;
|
||||
case 'q':
|
||||
$config['quiet'] = true;
|
||||
break;
|
||||
}
|
||||
|
||||
$this->config = (object)$config;
|
||||
@ -40,19 +44,22 @@ class Application
|
||||
printf("Usage: makephar [opts]\n");
|
||||
printf("Options: -h,--help Show this help\n");
|
||||
printf(" -n,--new Create a new configuration file\n");
|
||||
printf(" -q Quiet operation\n");
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
$this->parseCommandLine();
|
||||
|
||||
if ($this->config->quiet) {
|
||||
define("QUIET",true);
|
||||
}
|
||||
|
||||
if ($this->config->help) {
|
||||
$this->printHelp();
|
||||
return;
|
||||
}
|
||||
|
||||
log_info("MakePhar 2.0 - (c) 2016-2017, NoccyLabs");
|
||||
|
||||
if ($this->config->init) {
|
||||
if (!file_exists("composer.json")) {
|
||||
error_log("No composer.json in current directory");
|
||||
@ -62,6 +69,9 @@ class Application
|
||||
$proj_name = basename(getcwd()).".phar";
|
||||
$proj_files = [];
|
||||
$proj_dirs = [];
|
||||
printf("// makephar.sdl generated for %s\n", basename(getcwd()));
|
||||
printf("phar \"%s\" {\n", $proj_name);
|
||||
printf(" include {\n");
|
||||
if (!empty($proj->autoload)) {
|
||||
foreach ((array)$proj->autoload as $type=>$loaders) {
|
||||
if ($type == 'files') {
|
||||
@ -75,20 +85,22 @@ class Application
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("phar \"%s\" {\n", $proj_name);
|
||||
printf(" include {\n");
|
||||
foreach ($proj_files as $file)
|
||||
printf(" file \"%s\";\n", $file);
|
||||
foreach ($proj_dirs as $dir)
|
||||
printf(" dir \"%s\";\n", $dir);
|
||||
printf(" dir \"vendor\";\n");
|
||||
printf(" }\n");
|
||||
printf(" // stub \"src/path-to-stub.php\";\n");
|
||||
printf("}\n");
|
||||
} else {
|
||||
printf(" // file \"filename.php\" src=\"path/file.php\";\n");
|
||||
printf(" // dir \"path\";\n");
|
||||
}
|
||||
printf(" }\n");
|
||||
printf(" // stub \"src/path-to-stub.php\";\n");
|
||||
printf("}\n");
|
||||
|
||||
return;
|
||||
}
|
||||
log_info("MakePhar 2.0 - (c) 2016-2017, NoccyLabs");
|
||||
|
||||
$this->buildManifest();
|
||||
}
|
||||
|
Reference in New Issue
Block a user