Hoa central
State.php
Go to the documentation of this file.
1 <?php
2 
37 namespace Hoa\Devtools\Bin;
38 
39 use Hoa\Console;
40 
50 {
56  protected $options = [
57  ['help', Console\GetOption::NO_ARGUMENT, 'h'],
58  ['help', Console\GetOption::NO_ARGUMENT, '?']
59  ];
60 
61 
62 
68  public function main()
69  {
70  $library = null;
71 
72  while (false !== $c = $this->getOption($v)) {
73  switch ($c) {
74  case '__ambiguous':
75  $this->resolveOptionAmbiguity($v);
76 
77  break;
78 
79  case 'h':
80  case '?':
81  default:
82  return $this->usage();
83  }
84  }
85 
86  $this->parser->listInputs($library);
87 
88  if (empty($library)) {
89  return $this->usage();
90  }
91 
92  $library = ucfirst(strtolower($library));
93  $path = 'hoa://Library/' . $library;
94 
95  if (false === file_exists($path)) {
96  throw new Console\Exception(
97  'The %s library does not exist.',
98  0,
99  $library
100  );
101  }
102 
103  $status = 'beta';
104  $path .= '/.State';
105 
106  if (true === file_exists($path)) {
107  $status = trim(file_get_contents($path));
108  }
109 
110  echo $status;
111 
112  return;
113  }
114 
120  public function usage()
121  {
122  echo
123  'Usage : devtools:state <options> library', "\n",
124  'Options :', "\n",
125  $this->makeUsageOptionsList([
126  'help' => 'This help.'
127  ]), "\n";
128 
129  return;
130  }
131 }
132 
133 __halt_compiler();
134 Get the state of a library.
makeUsageOptionsList(Array $definitions=[])
Definition: Kit.php:149
getOption(&$optionValue, $short=null)
Definition: Kit.php:104
resolveOptionAmbiguity(Array $solutions)
Definition: Kit.php:190