innmind/cli-framework

This package is abandoned and no longer maintained. The author suggests using the innmind/framework package instead.

CLI framework

1.4.0 2021-02-20 10:19 UTC

This package is auto-updated.

Last update: 2023-01-01 15:05:15 UTC


README

codecov Build Status Type Coverage

Small library on top of innmind/cli to automatically enable some features.

Installation

composer require innmind/cli-framework

Usage

<?php

use Innmind\CLI\{
    Environment,
    Command,
};
use Innmind\CLI\Framework\{
    Application,
    Main,
};
use Innmind\OperatingSystem\OperatingSystem;
use Innmind\Url\Path;

new class extends Main {
    protected function configure(Application $app): Application
    {
        return $app
            ->configAt(Path::of('/path/to/config/directory/'))
            ->commands(fn(Environment $env, OperatingSystem $os): array => [
                // a list of objects implementing Command
            ]);
    }
}

This simple example will try to locate a file named .env in the directory provided and will add the variables to the map returned by $env->variables() in the commands callable.

By default it enables the usage of innmind/silent-cartographer, but can be disabled by calling ->disableSilentCartographer().

When a PROFILER environment variable is declared it will enable innmind/debug, you can disable specific sections of the profiler by calling ->disableProfilerSection(...$sectionsClassNameToDisable).

When your CLI application communicate with external services you should call ->useResilientOperatingSystem() so it accomodate inconsistencies due to unreliable network.