فهرست منبع

Added new command line option --no-description to gearman:worker:execute and gearman:job:execute which doesn't print worker or job description if present.

Vincent Simonin 13 سال پیش
والد
کامیت
285c542134
2فایلهای تغییر یافته به همراه18 افزوده شده و 8 حذف شده
  1. 9 4
      Command/GearmanJobExecuteCommand.php
  2. 9 4
      Command/GearmanWorkerExecuteCommand.php

+ 9 - 4
Command/GearmanJobExecuteCommand.php

@@ -24,7 +24,8 @@ class GearmanJobExecuteCommand extends ContainerAwareCommand
         parent::configure();
         $this->setName('gearman:job:execute')
              ->setDescription('Execute one single job')
-             ->addArgument('job', InputArgument::REQUIRED, 'job to execute');
+             ->addArgument('job', InputArgument::REQUIRED, 'job to execute')
+            ->addOption('no-description', null, InputOption::VALUE_NONE, 'Don\'t print job description');
     }
 
     /**
@@ -43,12 +44,16 @@ class GearmanJobExecuteCommand extends ContainerAwareCommand
         if (!$input->getOption('no-interaction') && !$dialog->askConfirmation($output, '<question>This will execute asked job?</question>', 'y')) {
             return;
         }
-        $output->writeln('<info>loading...</info>');
+        $output->writeln(sprintf('<info>[%s] loading...</info>', date('Y-m-d H:i:s')));
 
         $job = $input->getArgument('job');
         $jobStruct = $this->getContainer()->get('gearman')->getJob($job);
-        $this->getContainer()->get('gearman.describer')->describeJob($output, $jobStruct, true);
-        $output->writeln('<info>loaded. Ctrl+C to break</info>');
+
+        if (!$input->getOption('no-description')) {
+            $this->getContainer()->get('gearman.describer')->describeJob($output, $jobStruct, true);
+        }
+
+        $output->writeln(sprintf('<info>[%s] loaded. Ctrl+C to break</info>', date('Y-m-d H:i:s')));
         $this->getContainer()->get('gearman.execute')->executeJob($job);
     }
 }

+ 9 - 4
Command/GearmanWorkerExecuteCommand.php

@@ -24,7 +24,8 @@ class GearmanWorkerExecuteCommand extends ContainerAwareCommand
         parent::configure();
         $this->setName('gearman:worker:execute')
              ->setDescription('Execute one worker with all contained Jobs')
-             ->addArgument('worker', InputArgument::REQUIRED, 'work to execute');
+             ->addArgument('worker', InputArgument::REQUIRED, 'work to execute')
+             ->addOption('no-description', null, InputOption::VALUE_NONE, 'Don\'t print worker description');
     }
 
     /**
@@ -43,12 +44,16 @@ class GearmanWorkerExecuteCommand extends ContainerAwareCommand
         if (!$input->getOption('no-interaction') && !$dialog->askConfirmation($output, '<question>This will execute asked worker with all its jobs?</question>', 'y')) {
             return;
         }
-        $output->writeln('<info>loading...</info>');
+        $output->writeln(sprintf('<info>[%s] loading...</info>', date('Y-m-d H:i:s')));
 
         $worker = $input->getArgument('worker');
         $workerStruct = $this->getContainer()->get('gearman')->getWorker($worker);
-        $this->getContainer()->get('gearman.describer')->describeWorker($output, $workerStruct, true);
-        $output->writeln('<info>loaded. Ctrl+C to break</info>');
+
+        if (!$input->getOption('no-description')) {
+            $this->getContainer()->get('gearman.describer')->describeWorker($output, $workerStruct, true);
+        }
+
+        $output->writeln(sprintf('<info>[%s] loaded. Ctrl+C to break</info>', date('Y-m-d H:i:s')));
         $this->getContainer()->get('gearman.execute')->executeWorker($worker);
     }
 }