5 require_once __DIR__
."/Version.php";
10 * Command line arguments
11 * @var pharext\CliArgs
16 * Output pharext vX.Y.Z header
19 printf("pharext v%s (c) Michael Wallner <mike@php.net>\n\n", VERSION
);
23 * Output command line help message
26 public function help($prog) {
27 printf("Usage:\n\n \$ %s", $prog);
32 foreach ($this->args
->getSpec() as $spec) {
33 if ($spec[3] & CliArgs
::REQARG
) {
34 if ($spec[3] & CliArgs
::REQUIRED
) {
45 printf(" [-%s]", implode("", array_column($flags, 0)));
47 foreach ($required as $req) {
48 printf(" -%s <arg>", $req[0]);
51 printf(" [-%s <arg>]", implode("|-", array_column($optional, 0)));
54 $spc = $this->args
->getSpec();
55 $max = max(array_map("strlen", array_column($spc, 1)));
57 foreach ($spc as $spec) {
58 if (isset($spec[0])) {
59 printf(" -%s|", $spec[0]);
63 printf("--%s ", $spec[1]);
64 if ($spec[3] & CliArgs
::REQARG
) {
66 } elseif ($spec[3] & CliArgs
::OPTARG
) {
71 printf("%s%s", str_repeat(" ", $max-strlen($spec[1])+
3*!isset($spec[0])), $spec[2]);
72 if ($spec[3] & CliArgs
::REQUIRED
) {
73 printf(" (REQUIRED)");
75 if (isset($spec[4])) {
76 printf(" [%s]", $spec[4]);