virge/cli

There is no license information available for the latest version (v4.0.0) of this package.

Virge::Cli is used to create console commands in the Virge framework

v4.0.0 2018-02-27 21:59 UTC

This package is not auto-updated.

Last update: 2024-05-11 16:40:07 UTC


README

Used to create and run console commands

Creating a command

<?php

use Virge\Cli;
use Virge\Cli\Component\{
    Command,
    Input
};

class MyCommand extends Command
{
    const COMMAND = 'my_command';
    const COMMAND_HELP = 'some help text';
    const COMMAND_USAGE = 'my_command [--someOption] arg1';

    public function run(Input $input)
    {
        if($input->getOption('someOption')) {
            Cli::success("Something worked!");
        } else {
            Cli::error("Oops");
        }
    }
}

Cli::add(MyCommand::COMMAND, MyCommand::class)
->setHelpText(MyCommand::COMMAND_HELP)
->setUsage(MyCommand::COMMAND_USAGE)
;