Skip to content

Commit

Permalink
Initial Version
Browse files Browse the repository at this point in the history
  • Loading branch information
erikaheidi committed Apr 12, 2023
1 parent 1768676 commit a4028d0
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 33 deletions.
16 changes: 0 additions & 16 deletions Command/Demo/DefaultController.php

This file was deleted.

46 changes: 46 additions & 0 deletions Command/Help/DefaultController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace Librarian\Help;

use Minicli\App;
use Minicli\Command\CommandController;
use Minicli\Command\CommandRegistry;

class DefaultController extends CommandController
{
/** @var array */
protected array $commandMap = [];

public function boot(App $app): void
{
parent::boot($app);
$this->commandMap = $app->commandRegistry->getCommandMap();
}

public function handle(): void
{
$this->getPrinter()->info($this->app->getSignature());

$print_table[] = [ 'Namespace', 'Command' ];

foreach ($this->commandMap as $command => $sub) {
if ($command == 'web') {
continue;
}
$print_table[] = [ $command, ''];
if (is_array($sub)) {
foreach ($sub as $subcommand) {
if ($subcommand == 'default') {
$row = "./librarian $command\n";
} else {
$row = "./librarian $command $subcommand\n";
}

$print_table[] = [ '', $row ];
}
}
}

$this->getPrinter()->printTable($print_table);
}
}
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "minicli/command-demo",
"name": "librarianphp/command-demo",
"type": "library",
"description": "A demo shareable command for Minicli",
"description": "Librarian's built-in help command",
"license": "MIT",
"homepage": "https://github.com/minicli/command-demo",
"keywords": ["cli","command-line", "template"],
"homepage": "https://github.com/librarianphp/command-demo",
"keywords": ["cli","command-line", "markdown"],
"autoload": {
"psr-4": {
"Vendor\\": "Command/"
"Librarian\\": "Command/"
}
},
"require": {
Expand Down
19 changes: 8 additions & 11 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion minicli
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ $app = new App([
'debug' => true
]);

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

try {
$app->runCommand($argv);
Expand Down

0 comments on commit a4028d0

Please sign in to comment.