Created
February 6, 2021 19:42
-
-
Save tarlepp/12814d97a27b8d406bdcc7a6c78db41e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Command; | |
use Symfony\Component\Console\Command\Command; | |
use Symfony\Component\Console\Input\InputInterface; | |
use Symfony\Component\Console\Input\InputOption; | |
use Symfony\Component\Console\Output\OutputInterface; | |
use Symfony\Component\Console\Style\SymfonyStyle; | |
class YsyncCommand extends Command | |
{ | |
protected static $defaultName = 'ysync'; | |
protected function configure() | |
{ | |
$this | |
->addOption('dd', 'd', InputOption::VALUE_NONE, 'Option d description') | |
->addOption('aa', 'a', InputOption::VALUE_NONE, 'Option d description') | |
->addOption('pp', 'p', InputOption::VALUE_NONE, 'Option d description') | |
; | |
} | |
protected function execute(InputInterface $input, OutputInterface $output): int | |
{ | |
$io = new SymfonyStyle($input, $output); | |
if ($input->getOption('dd')) { | |
$io->info('do dd stuff'); | |
} elseif ($input->getOption('aa')) { | |
$io->info('do aa stuff'); | |
} elseif ($input->getOption('pp')) { | |
$io->info('do aa stuff'); | |
} else { | |
$io->error('please provide option d, a or p'); | |
return 1; | |
} | |
$io->success('You have a new command! Now make it your own! Pass --help to see your options.'); | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment