getkirby / cli

Kirby Command Line Interface
MIT License
52 stars 5 forks source link

add command to list all commands unformated #30

Open bnomei opened 1 year ago

bnomei commented 1 year ago

not like in help but just one item per line. why?

that can be used in further automations like fig.

CleanShot 2022-12-21 at 10 57 53@2x

bnomei commented 1 year ago

if you want to go deeper down the rabbit hole you could also create an publish a script to take care of that. https://fig.io/docs/getting-started

sadly there is no parser for PHP available yet so its manual work.

bnomei commented 1 year ago

i created one myself kirby make:command commands --global

<?php

declare(strict_types = 1);

use Kirby\CLI\CLI;

return [
    'description' => 'All commands',
    'command' => static function (CLI $cli): void {
        $commands = $cli->commands();

        foreach ($commands['core'] as $command) {
            $cli->out($command);
        }

        if (count($commands['global']) > 0) {
            foreach ($commands['global'] as $command) {
                $cli->out($command);
            }
        }

        if (count($commands['custom']) > 0) {
            foreach ($commands['custom'] as $command) {
                $cli->out($command);
            }
        }

        if (count($commands['plugins']) > 0) {
            foreach ($commands['plugins'] as $command) {
                $cli->out($command);
            }
        }
    }
];

but it would be nice to have this out-of-the-box