Hoa central
Public Member Functions | Protected Attributes | List of all members
Hoa\Test\Bin\Clean Class Reference
Inheritance diagram for Hoa\Test\Bin\Clean:

Public Member Functions

 main ()
 
 usage ()
 
- Public Member Functions inherited from Hoa\Console\Dispatcher\Kit
 __construct (Router $router, Dispatcher $dispatcher, View\Viewable $view=null)
 
 getOption (&$optionValue, $short=null)
 
 setOptions (Array $options)
 
 makeUsageOptionsList (Array $definitions=[])
 
 resolveOptionAmbiguity (Array $solutions)
 
 status ($text, $status)
 
 readLine ($prefix=null)
 
 readPassword ($prefix=null)
 
- Public Member Functions inherited from Hoa\Dispatcher\Kit
 __construct (Router $router, Dispatcher $dispatcher, View\Viewable $view=null)
 
 construct ()
 

Protected Attributes

 $options
 
- Protected Attributes inherited from Hoa\Console\Dispatcher\Kit
 $options = null
 
 $_options = null
 

Additional Inherited Members

- Public Attributes inherited from Hoa\Console\Dispatcher\Kit
 $parser = null
 
- Public Attributes inherited from Hoa\Dispatcher\Kit
 $router = null
 
 $dispatcher = null
 
 $view = null
 
 $data = null
 

Detailed Description

Class Hoa.

Clean generated tests.

Definition at line 50 of file Clean.php.

Member Function Documentation

Hoa\Test\Bin\Clean::main ( )

The entry method.

Returns
int

Definition at line 71 of file Clean.php.

72  {
73  $libraries = [];
74 
75  while (false !== $c = $this->getOption($v)) {
76  switch ($c) {
77  case 'a':
78  $iterator = new File\Finder();
79  $iterator->in(resolve('hoa://Library/', true, true))
80  ->directories()
81  ->maxDepth(1);
82 
83  foreach ($iterator as $fileinfo) {
84  $libraryName = $fileinfo->getBasename();
85  $pathname = resolve('hoa://Library/' . $libraryName);
86  $automaticTests = $pathname . DS . 'Test' . DS .
87  'Praspel' . DS;
88 
89  if (is_dir($automaticTests)) {
90  $libraries[] = $automaticTests;
91  }
92  }
93 
94  if (empty($libraries)) {
95  echo 'Already clean.';
96 
97  return;
98  }
99 
100  break;
101 
102  case 'l':
103  foreach ($this->parser->parseSpecialValue($v) as $library) {
104  $libraryName = ucfirst(strtolower($library));
105  $pathname = resolve('hoa://Library/' . $libraryName);
106  $automaticTests = $pathname . DS . 'Test' . DS .
107  'Praspel' . DS;
108 
109  if (is_dir($automaticTests)) {
110  $libraries[] = $automaticTests;
111  }
112  }
113 
114  if (empty($libraries)) {
115  echo 'Already clean.';
116 
117  return;
118  }
119 
120  break;
121 
122  case '__ambiguous':
123  $this->resolveOptionAmbiguity($v);
124 
125  break;
126 
127  case 'h':
128  case '?':
129  default:
130  return $this->usage();
131  }
132  }
133 
134  if (empty($libraries)) {
135  return $this->usage();
136  }
137 
138  foreach ($libraries as $path) {
139  $status =
140  'Clean ' .
141  (40 < strlen($path)
142  ? '…' . substr($path, -39)
143  : $path);
144  echo ' ⌛ ' , $status;
145 
146  $directory = new File\Directory($path);
147 
148  if (false === $directory->delete()) {
149  echo
150  ' ', Console\Chrome\Text::colorize('✖︎', 'foreground(red)'),
151  ' ', $status, "\n";
152  } else {
153  Console\Cursor::clear('↔');
154  echo
155  ' ', Console\Chrome\Text::colorize('✔︎', 'foreground(green)'),
156  ' ', $status, "\n";
157  }
158 
159  $directory->close();
160  }
161 
162  return;
163  }
static clear($parts= 'all')
Definition: Cursor.php:271
getOption(&$optionValue, $short=null)
Definition: Kit.php:104
resolveOptionAmbiguity(Array $solutions)
Definition: Kit.php:190
static colorize($text, $attributesBefore, $attributesAfter= 'normal')
Definition: Text.php:83

Here is the call graph for this function:

Hoa\Test\Bin\Clean::usage ( )

The command usage.

Returns
int

Definition at line 170 of file Clean.php.

171  {
172  echo
173  'Usage : test:clean <options>', "\n",
174  'Options :', "\n",
175  $this->makeUsageOptionsList([
176  'a' => 'Clean all generated tests of all libraries.',
177  'l' => 'Clean all generated tests of some libraries.',
178  'help' => 'This help.'
179  ]), "\n";
180 
181  return;
182  }
makeUsageOptionsList(Array $definitions=[])
Definition: Kit.php:149

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

Hoa\Test\Bin\Clean::$options
protected
Initial value:

Definition at line 57 of file Clean.php.


The documentation for this class was generated from the following file: