-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RunTemplate can be triggered using multiflexi-cli runtemplate trigger…
… RtplID
- Loading branch information
Showing
3 changed files
with
42 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,24 +8,56 @@ | |
*/ | ||
|
||
namespace MultiFlexi\Command; | ||
|
||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
/** | ||
* Description of RunTemplate | ||
* | ||
* @author Vitex <[email protected]> | ||
*/ | ||
class RunTemplate extends Command { | ||
protected function configure(): void | ||
{ | ||
class RunTemplate extends Command { | ||
|
||
protected function configure(): void { | ||
$this | ||
->setName('runtemplate') | ||
->setDescription('Runtemplate operations') | ||
->addOption('--format', '-f', InputOption::VALUE_OPTIONAL, 'The output format: text or json. Defaults to text.', 'text') | ||
->setHelp('This command manage Runtemplates'); | ||
->setName('runtemplate') | ||
->setDescription('Runtemplate operations') | ||
->addOption('--format', '-f', InputOption::VALUE_OPTIONAL, 'The output format: text or json. Defaults to text.', 'text') | ||
->addArgument('operation', InputArgument::REQUIRED, 'what to do with RunTemplate') | ||
->addArgument('id', InputArgument::OPTIONAL, 'which RunTemplate ?') | ||
->setHelp(<<<EOT | ||
The <info>runtemplate</info> command mangafe runtemplate | ||
<info>multilflexi-cli runtemplate trigger 220</info> | ||
<info>multilflexi-cli runtemplate list -f json</info> | ||
EOT); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): int { | ||
|
||
$runTemplate = new \MultiFlexi\RunTemplate(is_numeric($input->getArgument('id')) ? (int) $input->getArgument('id') : $input->getArgument('id')); | ||
|
||
switch ($input->getArgument('operation')) { | ||
case 'trigger': | ||
$jobber = new \MultiFlexi\Job(); | ||
$when = new \DateTime(); | ||
$executor = 'Native'; | ||
$customEnv = []; | ||
$prepared = $jobber->prepareJob($runTemplate->getMyKey(), $customEnv, $when, $executor, 'adhoc'); | ||
$jobber->scheduleJobRun($when); | ||
|
||
break; | ||
|
||
default: | ||
break; | ||
} | ||
|
||
|
||
return Command::SUCCESS; | ||
} | ||
} |
This file contains 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