diff --git a/Command/Demo/DefaultController.php b/Command/Demo/DefaultController.php deleted file mode 100644 index 30fe87d..0000000 --- a/Command/Demo/DefaultController.php +++ /dev/null @@ -1,16 +0,0 @@ -hasParam('user') ? $this->getParam('user') : 'World'; - $this->getPrinter()->display(sprintf("Hello, %s!", $name)); - - print_r($this->getParams()); - } -} \ No newline at end of file diff --git a/Command/Help/DefaultController.php b/Command/Help/DefaultController.php new file mode 100644 index 0000000..f37bcea --- /dev/null +++ b/Command/Help/DefaultController.php @@ -0,0 +1,46 @@ +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); + } +} diff --git a/composer.json b/composer.json index 01a1362..d7b4553 100644 --- a/composer.json +++ b/composer.json @@ -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": { diff --git a/composer.lock b/composer.lock index e9c0583..2c19182 100644 --- a/composer.lock +++ b/composer.lock @@ -4,23 +4,24 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d7c65dc97dcfa4fd7c7586c1ba56409f", + "content-hash": "faf2f1c5dd36510f52aa5e1a854fe6b1", "packages": [ { "name": "minicli/minicli", - "version": "3.0.2", + "version": "3.2.1", "source": { "type": "git", "url": "https://github.com/minicli/minicli.git", - "reference": "d0b8f64a13fd72dd5bc4e182482dbe9a0424f9cc" + "reference": "2d31b303461d0ec1f8c6d0be00f8b26be8766fbe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/minicli/minicli/zipball/d0b8f64a13fd72dd5bc4e182482dbe9a0424f9cc", - "reference": "d0b8f64a13fd72dd5bc4e182482dbe9a0424f9cc", + "url": "https://api.github.com/repos/minicli/minicli/zipball/2d31b303461d0ec1f8c6d0be00f8b26be8766fbe", + "reference": "2d31b303461d0ec1f8c6d0be00f8b26be8766fbe", "shasum": "" }, "require": { + "ext-readline": "*", "php": ">=8" }, "require-dev": { @@ -28,13 +29,9 @@ "pestphp/pest": "^1.0", "phpunit/phpunit": "^9.0" }, - "suggest": { - "ext-readline": "For obtaining user input" - }, "type": "library", "autoload": { "psr-4": { - "Assets\\": "tests/Assets", "Minicli\\": "src/" } }, @@ -50,7 +47,7 @@ ], "support": { "issues": "https://github.com/minicli/minicli/issues", - "source": "https://github.com/minicli/minicli/tree/3.0.2" + "source": "https://github.com/minicli/minicli/tree/3.2.1" }, "funding": [ { @@ -58,7 +55,7 @@ "type": "github" } ], - "time": "2022-05-31T17:20:54+00:00" + "time": "2022-09-23T09:04:22+00:00" } ], "packages-dev": [], diff --git a/minicli b/minicli index 560242e..06e5b93 100755 --- a/minicli +++ b/minicli @@ -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);