Skip to content

Commit 9c898ae

Browse files
committed
update commands desc
1 parent 1030f53 commit 9c898ae

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
.buildpath
33
.project
44
.settings/
5+
.idea/

src/Ubiquity/devtools/cmd/Command.php

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Command {
3333

3434
protected static $customAliases;
3535

36-
public function __construct($name = '', $value = '', $description = '', $aliases = [], $parameters = [], $examples = [], $category = 'custom') {
36+
public function __construct(string $name = '', string $value = '', string $description = '', array $aliases = [], array $parameters = [], array $examples = [], string $category = 'custom') {
3737
$this->name = $name;
3838
$this->value = $value;
3939
$this->description = $description;
@@ -51,22 +51,22 @@ public function longString() {
5151
$dec = "\t";
5252
$result = "\n<b>■ " . $this->name . "</b> [" . ConsoleFormatter::colorize($this->value, ConsoleFormatter::YELLOW) . "] =>";
5353
$result .= "\n" . $dec . "· " . $this->description;
54-
if (sizeof($this->aliases) > 0) {
54+
if (\count($this->aliases) > 0) {
5555
$result .= "\n" . $dec . "· Aliases :";
5656
$aliases = $this->aliases;
5757
array_walk($aliases, function (&$alias) {
5858
$alias = "<b>" . $alias . "</b>";
5959
});
6060
$result .= " " . implode(",", $aliases);
6161
}
62-
if (sizeof($this->parameters) > 0) {
62+
if (\count($this->parameters) > 0) {
6363
$result .= "\n" . $dec . "· Parameters :";
6464
foreach ($this->parameters as $param => $content) {
6565
$result .= "\n" . $dec . "\t<b>-" . $param . "</b>";
6666
$result .= $content . "\n";
6767
}
6868
}
69-
if (sizeof($this->examples) > 0) {
69+
if (\count($this->examples) > 0) {
7070
$result .= "\n" . $dec . "<b>× Samples :</b>";
7171
foreach ($this->examples as $desc => $sample) {
7272
if (is_string($desc)) {
@@ -90,12 +90,12 @@ public static function getInfo($cmd) {
9090
"cmd" => $command
9191
]
9292
];
93-
} elseif (array_search($cmd, $command->getAliases()) !== false) {
93+
} elseif (\array_search($cmd, $command->getAliases()) !== false) {
9494
$result[] = [
9595
"info" => "Command <b>{$cmd}</b> find by alias",
9696
"cmd" => $command
9797
];
98-
} elseif (stripos($command->getDescription(), $cmd) !== false) {
98+
} elseif (\stripos($command->getDescription(), $cmd) !== false) {
9999
$result[] = [
100100
"info" => "Command <b>{$cmd}</b> find in description",
101101
"cmd" => $command
@@ -109,7 +109,7 @@ public static function getInfo($cmd) {
109109
"cmd" => $command
110110
];
111111
}
112-
if (stripos($parameter->getDescription(), $cmd) !== false) {
112+
if (\stripos($parameter->getDescription(), $cmd) !== false) {
113113
$result[] = [
114114
"info" => "Command <b>{$cmd}</b> find in parameter description",
115115
"cmd" => $command
@@ -263,7 +263,7 @@ public static function serve() {
263263
"h" => Parameter::create("host", "Sets the host ip address.", [], '127.0.0.1'),
264264
"p" => Parameter::create("port", "Sets the listen port number.", [], 8090),
265265
"n" => Parameter::create("nolr", "Starts without live-reload.", [], false),
266-
"l" => Parameter::create("lrport", "Sets the live-reload listen port number.", [], 35729),
266+
"l" => Parameter::create("lrport", "Sets the live-reload listen port number.", [], '35729'),
267267
"t" => Parameter::create("type", "Sets the server type.", [
268268
'php',
269269
'react',
@@ -326,7 +326,8 @@ public static function crudController() {
326326
"form",
327327
"display"
328328
], "index,form,display"),
329-
"p" => Parameter::create("path", "The associated route", [])
329+
"p" => Parameter::create("path", "The associated route", []),
330+
'o' => Parameter::create('domain', 'The domain in which to create the controller.', [], '')
330331
], [
331332
'Creates a crud controller for the class models\User' => 'Ubiquity crud CrudUsers -r=User',
332333
'and associates a route to it' => 'Ubiquity crud CrudUsers -r=User -p=/users',
@@ -360,7 +361,8 @@ public static function indexCrudController() {
360361
], "index,form,display,home,itemHome"),
361362
"p" => Parameter::create("path", "The associated route", [
362363
'{resource}'
363-
])
364+
]),
365+
'o' => Parameter::create('domain', 'The domain in which to create the controller.', [], '')
364366
], [
365367
'Creates an index crud controller' => 'Ubiquity crud-index MainCrud -p=crud/{resource}',
366368
'allows customization of index and form templates' => 'Ubiquity index-crud MainCrud -t=index,form'
@@ -437,7 +439,7 @@ public static function newAction() {
437439
"true",
438440
"false"
439441
], "false"),
440-
'o' => Parameter::create('domain', 'The domain in which to create the models.', [], '')
442+
'o' => Parameter::create('domain', 'The domain in which the controller is.', [], '')
441443
], [
442444
'Adds the action all in controller Users' => 'Ubiquity action Users.all',
443445
'Adds the action display in controller Users with a parameter' => 'Ubiquity action Users.display -p=idUser',
@@ -793,7 +795,7 @@ public function getDescription() {
793795
*/
794796
public function getValue() {
795797
if ($this->value != null) {
796-
return ltrim($this->value, '?');
798+
return \ltrim($this->value, '?');
797799
}
798800
return $this->value;
799801
}
@@ -843,7 +845,7 @@ public function setCategory($category) {
843845
}
844846

845847
public function hasParameters() {
846-
return count($this->parameters) > 0;
848+
return \count($this->parameters) > 0;
847849
}
848850

849851
public function hasValue() {

src/Ubiquity/devtools/cmd/Parameter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Parameter {
2020

2121
protected $defaultValue;
2222

23-
public function __construct($name = '', $description = '', $values = [], $defaultValue = "") {
23+
public function __construct(string $name = '', string $description = '', array $values = [], string $defaultValue = "") {
2424
$this->name = $name;
2525
$this->description = $description;
2626
$this->values = $values;
@@ -30,7 +30,7 @@ public function __construct($name = '', $description = '', $values = [], $defaul
3030
public function __toString() {
3131
$dec = "\t\t\t";
3232
$result = "\tshortcut of --<b>" . $this->name . "</b>\n" . $dec . $this->description;
33-
if (sizeof($this->values) > 0) {
33+
if (\count($this->values) > 0) {
3434
$result .= "\n" . $dec . "Possibles values :";
3535
$result .= "\n" . $dec . ConsoleFormatter::colorize(implode(",", $this->values), ConsoleFormatter::DARK_GREY);
3636
}
@@ -89,7 +89,7 @@ public function setDefaultValue($defaultValue) {
8989
* The default value
9090
* @return \Ubiquity\devtools\cmd\Parameter
9191
*/
92-
public static function create($name, $description, $values, $defaultValue = "") {
92+
public static function create(string $name, string $description, array $values, string $defaultValue = "") {
9393
return new Parameter($name, $description, $values, $defaultValue);
9494
}
9595
}

0 commit comments

Comments
 (0)