Defining Options

Flag Options

To add options that behave like flags to your command, you may use the FlagOption attribute.

use Illuminate\Console\Command;
use WendellAdriel\Virtue\Commands\Attributes\FlagOption;
use WendellAdriel\Virtue\Commands\Concerns\Virtue;

#[FlagOption(name: 'negative', shortcut: 'm', negatable: true)]
final class TestCommand extends Command
{
    use Virtue;

    protected $name = 'app:test';

    protected $description = 'Command description';

    public function handle()
    {
        // Command code here
    }
}

These are the available properties to define your flag options:

Flags that set the negatable as true can be used like this:

Value Options

To add options that can have values set to them to your command, you may use the ValueOption attribute.

These are the available properties to define your flag options:

Last updated

Was this helpful?