innmind/cli-framework

1.2.0 2020-05-17 13:10 UTC

This package is auto-updated.

Last update: 2020-07-30 12:58:32 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.