namespace pharext;
use Phar;
-use pharext\Cli\Command as CliCommand;
-use pharext\Exception;
/**
* The extension packaging command executed by bin/pharext
*/
class Packager implements Command
{
- use CliCommand;
+ use Cli\Command;
/**
* Extension source directory
["S", "sign", "Sign the PHAR with a private key",
Cli\Args::OPTIONAL|Cli\Args::SINGLE|Cli\Args::REQARG],
["E", "zend", "Mark as Zend Extension",
- Cli\Args::OPTIONAL|CliARgs::SINGLE|Cli\Args::NOARG],
+ Cli\Args::OPTIONAL|Cli\Args::SINGLE|Cli\Args::NOARG],
[null, "signature", "Show pharext signature",
Cli\Args::OPTIONAL|Cli\Args::SINGLE|Cli\Args::NOARG|Cli\Args::HALT],
[null, "license", "Show pharext license",
try {
/* source needs to be evaluated before Cli\Args validation,
- * so e.g. name and version can be overriden and Cli\Args
- * does not complain about missing arguments
+ * so Cli\Args does not complain about missing arguments,
+ * which come from SourceDir::getPackageInfo()
*/
$this->loadSource();
} catch (\Exception $e) {
$source = $this->download($source);
$this->cleanup[] = new Task\Cleanup($source);
}
- $source = realpath($source);
- if (!is_dir($source)) {
- $source = $this->extract($source);
+ if (!$real = realpath($source)) {
+ $error = "Cannot find source '$source'";
+ if ($this->args->git) {
+ $error .= "; did you forget to specify --branch for a remote git source?";
+ }
+ throw new Exception($error);
+ }
+ if (!is_dir($real)) {
+ $source = $this->extract($real);
$this->cleanup[] = new Task\Cleanup($source);
if (!$this->args->git) {
}
foreach ($this->source->getPackageInfo() as $key => $val) {
- $this->args->$key = $val;
+ /* do not override command line arguments */
+ if (!isset($this->args->$key)) {
+ $this->args->$key = $val;
+ }
}
}
}