6b91aeb41a4235731efaed9e60dbb2be053023c6
13 * Command line arguments
20 * @see \pharext\Command::getArgs()
22 public function getArgs() {
27 * Retrieve metadata of the currently running phar
31 public function metadata($key = null) {
33 if (extension_loaded("Phar")) {
34 $running = new Phar(Phar
::running(false));
36 $running = new Archive(PHAREXT_PHAR
);
39 if ($key === "signature") {
40 $sig = $running->getSignature();
41 return sprintf("%s signature of %s\n%s",
43 $this->metadata("name"),
44 chunk_split($sig["hash"], 64, "\n"));
47 $metadata = $running->getMetadata();
48 } catch (\Exception
$e) {
49 $metadata = Metadata
::all();
52 return $metadata[$key];
58 * Output pharext vX.Y.Z header
60 public function header() {
61 if (!headers_sent()) {
62 /* only display header, if we didn't generate any output yet */
63 printf("%s\n\n", $this->metadata("header"));
69 * @see \pharext\Command::debug()
71 public function debug($fmt) {
72 if ($this->args
->verbose
) {
73 vprintf($fmt, array_slice(func_get_args(), 1));
79 * @see \pharext\Command::info()
81 public function info($fmt) {
82 if (!$this->args
->quiet
) {
83 vprintf($fmt, array_slice(func_get_args(), 1));
89 * @see \pharext\Command::warn()
91 public function warn($fmt) {
92 if (!$this->args
->quiet
) {
95 $arg = error_get_last()["message"];
97 $arg = array_slice(func_get_args(), 1);
99 vfprintf(STDERR
, "Warning: $fmt", $arg);
105 * @see \pharext\Command::error()
107 public function error($fmt) {
110 $arg = error_get_last()["message"];
112 $arg = array_slice(func_get_args(), 1);
114 vfprintf(STDERR
, "ERROR: $fmt", $arg);
118 * Output command line help message
119 * @param string $prog
121 public function help($prog) {
122 print new Args\
Help($prog, $this->args
);
129 public function verbosity() {
130 if ($this->args
->verbose
) {
132 } elseif ($this->args
->quiet
) {