@@ -75,8 +75,9 @@ |
||
| 75 | 75 | |
| 76 | 76 | $ss = S::syntax(); |
| 77 | 77 | |
| 78 | - if (!$ss->canParse($syntax)) |
|
| 79 | - throw new SyntaxBuilderException("Invalid Syntax: '{$syntax}'"); |
|
| 78 | + if (!$ss->canParse($syntax)) { |
|
| 79 | + throw new SyntaxBuilderException("Invalid Syntax: '{$syntax}'"); |
|
| 80 | + } |
|
| 80 | 81 | |
| 81 | 82 | return $ss->parse($syntax); |
| 82 | 83 | } |
@@ -19,8 +19,8 @@ |
||
| 19 | 19 | { |
| 20 | 20 | $c = $this->parent(); |
| 21 | 21 | $this->console |
| 22 | - ->green()->inline($c->name()) |
|
| 23 | - ->white()->inline(' version ') |
|
| 24 | - ->yellow()->out($c->version()); |
|
| 22 | + ->green()->inline($c->name()) |
|
| 23 | + ->white()->inline(' version ') |
|
| 24 | + ->yellow()->out($c->version()); |
|
| 25 | 25 | } |
| 26 | 26 | } |
@@ -35,15 +35,15 @@ discard block |
||
| 35 | 35 | $c = $this->console(); |
| 36 | 36 | |
| 37 | 37 | $c->br() |
| 38 | - ->green() |
|
| 39 | - ->inline($command->name() . ' ') |
|
| 40 | - ->yellow() |
|
| 41 | - ->out($command->version()) |
|
| 42 | - ->br() |
|
| 43 | - ->out($command->description()) |
|
| 44 | - ->br() |
|
| 45 | - ->yellow() |
|
| 46 | - ->inline('Arguments: '); |
|
| 38 | + ->green() |
|
| 39 | + ->inline($command->name() . ' ') |
|
| 40 | + ->yellow() |
|
| 41 | + ->out($command->version()) |
|
| 42 | + ->br() |
|
| 43 | + ->out($command->description()) |
|
| 44 | + ->br() |
|
| 45 | + ->yellow() |
|
| 46 | + ->inline('Arguments: '); |
|
| 47 | 47 | |
| 48 | 48 | $args = F\s(array_keys($command->syntax()->fields())) |
| 49 | 49 | ->then(F\join(' ')) |
@@ -67,9 +67,9 @@ discard block |
||
| 67 | 67 | ->get() * 2; |
| 68 | 68 | foreach ($command->subCommands() as $name => $cmd) { |
| 69 | 69 | $c->tab() |
| 70 | - ->padding($padding)->char(' ') |
|
| 71 | - ->label("<green>{$name}</green>") |
|
| 72 | - ->result($cmd->description()); |
|
| 70 | + ->padding($padding)->char(' ') |
|
| 71 | + ->label("<green>{$name}</green>") |
|
| 72 | + ->result($cmd->description()); |
|
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | } |
@@ -86,8 +86,8 @@ discard block |
||
| 86 | 86 | $c->out("(Required)"); |
| 87 | 87 | } else { |
| 88 | 88 | $c->inline("(default: ") |
| 89 | - ->white()->inline(json_encode($syntax->getDefault())) |
|
| 90 | - ->yellow()->out(" )"); |
|
| 89 | + ->white()->inline(json_encode($syntax->getDefault())) |
|
| 90 | + ->yellow()->out(" )"); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | if ($syntax instanceof ArraySyntax) { |
@@ -24,10 +24,11 @@ |
||
| 24 | 24 | protected function execute () |
| 25 | 25 | { |
| 26 | 26 | $command = trim($this->args->command); |
| 27 | - if (empty($command) || !$this->parent()->hasCommand($command)) |
|
| 28 | - $this->showHelpOf($this->parent); |
|
| 29 | - else |
|
| 30 | - $this->showHelpOf($this->parent->command($command)); |
|
| 27 | + if (empty($command) || !$this->parent()->hasCommand($command)) { |
|
| 28 | + $this->showHelpOf($this->parent); |
|
| 29 | + } else { |
|
| 30 | + $this->showHelpOf($this->parent->command($command)); |
|
| 31 | + } |
|
| 31 | 32 | } |
| 32 | 33 | |
| 33 | 34 | protected function showHelpOf (Command $command) |
@@ -63,8 +63,9 @@ |
||
| 63 | 63 | */ |
| 64 | 64 | public function fs (Filesystem $value = null) |
| 65 | 65 | { |
| 66 | - if (null === $value) |
|
| 67 | - return $this->fs; |
|
| 66 | + if (null === $value) { |
|
| 67 | + return $this->fs; |
|
| 68 | + } |
|
| 68 | 69 | $this->fs = $value; |
| 69 | 70 | return $this; |
| 70 | 71 | } |
@@ -328,7 +328,7 @@ |
||
| 328 | 328 | |
| 329 | 329 | else |
| 330 | 330 | $this->args($this->syntax()->parse($args)) |
| 331 | - ->execute(); |
|
| 331 | + ->execute(); |
|
| 332 | 332 | } |
| 333 | 333 | } catch (\Exception $e) { |
| 334 | 334 | $this->error( |
@@ -109,8 +109,9 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | public function name ($value = null) |
| 111 | 111 | { |
| 112 | - if (null === $value) |
|
| 113 | - return $this->name; |
|
| 112 | + if (null === $value) { |
|
| 113 | + return $this->name; |
|
| 114 | + } |
|
| 114 | 115 | |
| 115 | 116 | $this->name = $value; |
| 116 | 117 | return $this; |
@@ -124,8 +125,9 @@ discard block |
||
| 124 | 125 | */ |
| 125 | 126 | public function description ($value = null) |
| 126 | 127 | { |
| 127 | - if (null === $value) |
|
| 128 | - return $this->description; |
|
| 128 | + if (null === $value) { |
|
| 129 | + return $this->description; |
|
| 130 | + } |
|
| 129 | 131 | |
| 130 | 132 | $this->description = $value; |
| 131 | 133 | return $this; |
@@ -139,8 +141,9 @@ discard block |
||
| 139 | 141 | */ |
| 140 | 142 | public function version ($value = null) |
| 141 | 143 | { |
| 142 | - if (null === $value) |
|
| 143 | - return $this->version; |
|
| 144 | + if (null === $value) { |
|
| 145 | + return $this->version; |
|
| 146 | + } |
|
| 144 | 147 | |
| 145 | 148 | $this->version = $value; |
| 146 | 149 | return $this; |
@@ -154,8 +157,9 @@ discard block |
||
| 154 | 157 | */ |
| 155 | 158 | public function console ($value = null) |
| 156 | 159 | { |
| 157 | - if (null === $value) |
|
| 158 | - return $this->console; |
|
| 160 | + if (null === $value) { |
|
| 161 | + return $this->console; |
|
| 162 | + } |
|
| 159 | 163 | |
| 160 | 164 | $this->console = $value; |
| 161 | 165 | return $this; |
@@ -170,8 +174,9 @@ discard block |
||
| 170 | 174 | */ |
| 171 | 175 | public function syntax ($value = null) |
| 172 | 176 | { |
| 173 | - if (null === $value) |
|
| 174 | - return $this->syntaxBuilder->get(); |
|
| 177 | + if (null === $value) { |
|
| 178 | + return $this->syntaxBuilder->get(); |
|
| 179 | + } |
|
| 175 | 180 | |
| 176 | 181 | $this->syntaxBuilder = SyntaxBuilder::of($value); |
| 177 | 182 | |
@@ -219,8 +224,9 @@ discard block |
||
| 219 | 224 | public function command ($name, Command $cmd = null) |
| 220 | 225 | { |
| 221 | 226 | if (null === $cmd) { |
| 222 | - if (!$this->hasCommand($name)) |
|
| 223 | - throw new CommandNotFound("Command '{$this->name}' has no subcommand '{$name}'"); |
|
| 227 | + if (!$this->hasCommand($name)) { |
|
| 228 | + throw new CommandNotFound("Command '{$this->name}' has no subcommand '{$name}'"); |
|
| 229 | + } |
|
| 224 | 230 | return $this->subCommands[$name]; |
| 225 | 231 | } |
| 226 | 232 | |
@@ -246,8 +252,9 @@ discard block |
||
| 246 | 252 | */ |
| 247 | 253 | public function args($value = null) |
| 248 | 254 | { |
| 249 | - if (null === $value) |
|
| 250 | - return $this->args; |
|
| 255 | + if (null === $value) { |
|
| 256 | + return $this->args; |
|
| 257 | + } |
|
| 251 | 258 | |
| 252 | 259 | $this->args = $value; |
| 253 | 260 | return $this; |
@@ -307,10 +314,12 @@ discard block |
||
| 307 | 314 | { |
| 308 | 315 | try { |
| 309 | 316 | |
| 310 | - if (null === $args) |
|
| 311 | - $args = $this->consoleArguments(); |
|
| 312 | - if (null === $console) |
|
| 313 | - $console = new CLImate; |
|
| 317 | + if (null === $args) { |
|
| 318 | + $args = $this->consoleArguments(); |
|
| 319 | + } |
|
| 320 | + if (null === $console) { |
|
| 321 | + $console = new CLImate; |
|
| 322 | + } |
|
| 314 | 323 | |
| 315 | 324 | $firstArg = F\head(F\split(' ', $args)); |
| 316 | 325 | if ($this->hasCommand($firstArg)) { |
@@ -324,11 +333,10 @@ discard block |
||
| 324 | 333 | ->then(F\join(PHP_EOL)) |
| 325 | 334 | ->get(); |
| 326 | 335 | $this->error($errors); |
| 327 | - } |
|
| 328 | - |
|
| 329 | - else |
|
| 330 | - $this->args($this->syntax()->parse($args)) |
|
| 336 | + } else { |
|
| 337 | + $this->args($this->syntax()->parse($args)) |
|
| 331 | 338 | ->execute(); |
| 339 | + } |
|
| 332 | 340 | } |
| 333 | 341 | } catch (\Exception $e) { |
| 334 | 342 | $this->error( |
@@ -347,8 +355,9 @@ discard block |
||
| 347 | 355 | */ |
| 348 | 356 | protected function template($name) |
| 349 | 357 | { |
| 350 | - if (null === $this->templateLoader) |
|
| 351 | - throw new NullPropertyAccess("The templatesLoader is not initialized; Please set it before trying to load a template !"); |
|
| 358 | + if (null === $this->templateLoader) { |
|
| 359 | + throw new NullPropertyAccess("The templatesLoader is not initialized; Please set it before trying to load a template !"); |
|
| 360 | + } |
|
| 352 | 361 | |
| 353 | 362 | return $this->templateLoader->load($name); |
| 354 | 363 | } |