01c50c4f3feb1393a45d1979250e138738804956
12 * Command line arguments
13 * @var pharext\Cli\Args
19 * @see \pharext\Command::getArgs()
21 public function getArgs() {
26 * Retrieve metadata of the currently running phar
30 public function metadata($key = null) {
31 if (extension_loaded("Phar")) {
32 $running = new Phar(Phar
::running(false));
34 $running = new Archive(PHAREXT_PHAR
);
37 if ($key === "signature") {
38 $sig = $running->getSignature();
39 return sprintf("%s signature of %s\n%s",
41 $this->metadata("name"),
42 chunk_split($sig["hash"], 64, "\n"));
45 $metadata = $running->getMetadata();
47 return $metadata[$key];
53 * Output pharext vX.Y.Z header
55 public function header() {
56 if (!headers_sent()) {
57 /* only display header, if we didn't generate any output yet */
58 printf("%s\n\n", $this->metadata("header"));
64 * @see \pharext\Command::debug()
66 public function debug($fmt) {
67 if ($this->args
->verbose
) {
68 vprintf($fmt, array_slice(func_get_args(), 1));
74 * @see \pharext\Command::info()
76 public function info($fmt) {
77 if (!$this->args
->quiet
) {
78 vprintf($fmt, array_slice(func_get_args(), 1));
84 * @see \pharext\Command::warn()
86 public function warn($fmt) {
87 if (!$this->args
->quiet
) {
90 $arg = error_get_last()["message"];
92 $arg = array_slice(func_get_args(), 1);
94 vfprintf(STDERR
, "Warning: $fmt", $arg);
100 * @see \pharext\Command::error()
102 public function error($fmt) {
105 $arg = error_get_last()["message"];
107 $arg = array_slice(func_get_args(), 1);
109 vfprintf(STDERR
, "ERROR: $fmt", $arg);
113 * Output command line help message
114 * @param string $prog
116 public function help($prog) {
117 print new Args\
Help($prog, $this->args
);
124 public function verbosity() {
125 if ($this->args
->verbose
) {
127 } elseif ($this->args
->quiet
) {