Skip to content

Commit d1e97d1

Browse files
committed
Added command help
1 parent e100214 commit d1e97d1

File tree

4 files changed

+30
-18
lines changed

4 files changed

+30
-18
lines changed

app/bootstrap.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,11 @@
3636
* Process the console arguments
3737
*/
3838
$arguments = [];
39+
$arguments['task'] = count($argv) >= 2 ? ($argv[1] == "help" ? "help" : "main") : "main";
40+
$arguments['action'] = "main";
3941

4042
foreach ($argv as $k => $arg) {
41-
if ($k == 1) {
42-
$arguments['task'] = $arg;
43-
} elseif ($k == 2) {
44-
$arguments['action'] = $arg;
45-
} elseif ($k >= 3) {
43+
if ($k >= 1) {
4644
$arguments['params'][] = $arg;
4745
}
4846
}

app/tasks/HelpTask.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
class HelpTask extends \Phalcon\Cli\Task
4+
{
5+
public function mainAction()
6+
{
7+
$config = $this->getDI()->get('config');
8+
9+
echo PHP_EOL, PHP_EOL;
10+
echo "PhalconFormGenerator ({$config['version']})";
11+
echo PHP_EOL, PHP_EOL;
12+
echo "Help:", PHP_EOL;
13+
echo "This script can generate form fields based on a database.", PHP_EOL;
14+
echo "Step 1:", PHP_EOL;
15+
echo "Edit database configuration in `./app/config/config.php`", PHP_EOL;
16+
echo "Step 2:", PHP_EOL;
17+
echo "Simply run `./run` to generate the files.";
18+
echo PHP_EOL, PHP_EOL;
19+
echo "Usage:", PHP_EOL;
20+
echo "./run [namespace] [trait]", PHP_EOL;
21+
echo PHP_EOL, PHP_EOL;
22+
echo "Arguments:", PHP_EOL;
23+
echo "help", PHP_EOL;
24+
}
25+
26+
}

app/tasks/MainTask.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class MainTask extends \Phalcon\Cli\Task
44
{
5-
public function mainAction()
5+
public function mainAction($namespace = 'null', $trait = 'null')
66
{
77
echo "Congratulations! You are now flying with Phalcon CLI!";
88
}

app/tasks/VersionTask.php

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)