Skip to content

Commit 31db1fc

Browse files
authored
Initial commit
0 parents  commit 31db1fc

File tree

11 files changed

+5009
-0
lines changed

11 files changed

+5009
-0
lines changed

.github/workflows/php.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: PHP Composer
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
17+
- name: Validate composer.json and composer.lock
18+
run: composer validate
19+
20+
- name: Install dependencies
21+
run: composer install --prefer-dist --no-progress
22+
23+
- name: Run test suite
24+
run: composer test
25+
26+
- name: Run php-cs-fixer
27+
run: composer csfix .

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea
2+
.phpunit.result.cache
3+
.composer/
4+
vendor/

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 librarianphp\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+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 minicli
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# command-help
2+
3+
Librarian's built-in help command.
4+
5+
```shell
6+
./librarian help
7+
```

composer.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "librarianphp/command-help",
3+
"type": "library",
4+
"description": "Librarian's built-in help command",
5+
"license": "MIT",
6+
"homepage": "https://github.com/librarianphp/command-demo",
7+
"keywords": ["cli","command-line", "markdown"],
8+
"autoload": {
9+
"psr-4": {
10+
"librarianphp\\": "Command/"
11+
}
12+
},
13+
"require": {
14+
"minicli/minicli": "^3.2"
15+
},
16+
"require-dev": {
17+
"pestphp/pest": "^2.4",
18+
"friendsofphp/php-cs-fixer": "^3.16"
19+
},
20+
"scripts": {
21+
"test" : ["pest"],
22+
"csfix": ["php-cs-fixer fix"]
23+
},
24+
25+
"config": {
26+
"allow-plugins": {
27+
"pestphp/pest-plugin": true
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)