You can display all options available for a command with calling it with -h
or --help
option:
php artisan yourcommand -h
To add description to parameters use this syntax:
protected $signature = 'yourcommand {someargument : Description of option}';
If you want to do that programmatically, create a public method in the command class:
public function help()
{
// Display all arguments with descriptions.
foreach($this->getDefinition()->getArguments() as $name => $description) {
echo $name . ' - ' . $description->getDescription();
};
// Display all options with descriptions.
foreach($this->getDefinition()->getOptions() as $name => $description) {
echo $name . ' - ' . $description->getDescription();
};
}
Then call it from your code:
app('\App\Console\Commands\YourCommand')->help();