Skip to content

Commit a4028d0

Browse files
committed
Initial Version
1 parent 1768676 commit a4028d0

File tree

5 files changed

+60
-33
lines changed

5 files changed

+60
-33
lines changed

Command/Demo/DefaultController.php

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

Command/Help/DefaultController.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
namespace Librarian\Help;
4+
5+
use Minicli\App;
6+
use Minicli\Command\CommandController;
7+
use Minicli\Command\CommandRegistry;
8+
9+
class DefaultController extends CommandController
10+
{
11+
/** @var array */
12+
protected array $commandMap = [];
13+
14+
public function boot(App $app): void
15+
{
16+
parent::boot($app);
17+
$this->commandMap = $app->commandRegistry->getCommandMap();
18+
}
19+
20+
public function handle(): void
21+
{
22+
$this->getPrinter()->info($this->app->getSignature());
23+
24+
$print_table[] = [ 'Namespace', 'Command' ];
25+
26+
foreach ($this->commandMap as $command => $sub) {
27+
if ($command == 'web') {
28+
continue;
29+
}
30+
$print_table[] = [ $command, ''];
31+
if (is_array($sub)) {
32+
foreach ($sub as $subcommand) {
33+
if ($subcommand == 'default') {
34+
$row = "./librarian $command\n";
35+
} else {
36+
$row = "./librarian $command $subcommand\n";
37+
}
38+
39+
$print_table[] = [ '', $row ];
40+
}
41+
}
42+
}
43+
44+
$this->getPrinter()->printTable($print_table);
45+
}
46+
}

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
2-
"name": "minicli/command-demo",
2+
"name": "librarianphp/command-demo",
33
"type": "library",
4-
"description": "A demo shareable command for Minicli",
4+
"description": "Librarian's built-in help command",
55
"license": "MIT",
6-
"homepage": "https://github.com/minicli/command-demo",
7-
"keywords": ["cli","command-line", "template"],
6+
"homepage": "https://github.com/librarianphp/command-demo",
7+
"keywords": ["cli","command-line", "markdown"],
88
"autoload": {
99
"psr-4": {
10-
"Vendor\\": "Command/"
10+
"Librarian\\": "Command/"
1111
}
1212
},
1313
"require": {

composer.lock

Lines changed: 8 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

minicli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ $app = new App([
1717
'debug' => true
1818
]);
1919

20-
$app->setSignature('./minicli demo param1=value1 param2=value2');
20+
$app->setSignature('./minicli help');
2121

2222
try {
2323
$app->runCommand($argv);

0 commit comments

Comments
 (0)