6 use pharext\Cli\Args
as CliArgs
;
13 * Command line arguments
14 * @var pharext\CliArgs
20 * @see \pharext\Command::getArgs()
22 public function getArgs() {
27 * Retrieve metadata of the currently running phar
31 public function metadata($key = null) {
32 if (extension_loaded("Phar")) {
33 $running = new Phar(Phar
::running(false));
35 $running = new Archive(PHAREXT_PHAR
);
38 if ($key === "signature") {
39 $sig = $running->getSignature();
40 return sprintf("%s signature of %s\n%s",
42 $this->metadata("name"),
43 chunk_split($sig["hash"], 64, "\n"));
46 $metadata = $running->getMetadata();
48 return $metadata[$key];
54 * Output pharext vX.Y.Z header
56 public function header() {
57 if (!headers_sent()) {
58 /* only display header, if we didn't generate any output yet */
59 printf("%s\n\n", $this->metadata("header"));
65 * @see \pharext\Command::debug()
67 public function debug($fmt) {
68 if ($this->args
->verbose
) {
69 vprintf($fmt, array_slice(func_get_args(), 1));
75 * @see \pharext\Command::info()
77 public function info($fmt) {
78 if (!$this->args
->quiet
) {
79 vprintf($fmt, array_slice(func_get_args(), 1));
85 * @see \pharext\Command::warn()
87 public function warn($fmt) {
88 if (!$this->args
->quiet
) {
91 $arg = error_get_last()["message"];
93 $arg = array_slice(func_get_args(), 1);
95 vfprintf(STDERR
, "Warning: $fmt", $arg);
101 * @see \pharext\Command::error()
103 public function error($fmt) {
106 $arg = error_get_last()["message"];
108 $arg = array_slice(func_get_args(), 1);
110 vfprintf(STDERR
, "ERROR: $fmt", $arg);
114 * Output command line help message
115 * @param string $prog
117 public function help($prog) {
118 print new Args\
Help($prog, $this->args
);
125 public function verbosity() {
126 if ($this->args
->verbose
) {
128 } elseif ($this->args
->quiet
) {