execute() 공개 메소드

Execute the command
public execute ( ) : boolean
리턴 boolean whether execution was successful. If false, error details can be obtained through getError(), getStdErr() and getExitCode().
예제 #1
0
파일: Tor.php 프로젝트: yadakhov/tor
 /**
  * Execute tor command
  *
  * @param $command
  * @return Command|string
  */
 public function command($command)
 {
     if (!in_array($command, ['start', 'stop', 'restart', 'reload', 'force-reload', 'status'])) {
         throw new \InvalidArgumentException($command);
     }
     $command = 'sudo /etc/init.d/tor ' . $command;
     $command = new Command($command);
     $command->execute();
     return $command;
 }
예제 #2
0
 /**
  * Displays application version from git describe and writes it to `version`
  */
 public function actionVersion($alias = '@app/version')
 {
     echo "Application Version\n";
     $cmd = new Command("git describe --dirty");
     if ($cmd->execute()) {
         echo $cmd->getOutput();
         file_put_contents(\Yii::getAlias($alias), $cmd->getOutput());
     } else {
         echo $cmd->getOutput();
         echo $cmd->getStdErr();
         echo $cmd->getError();
     }
     echo "\n";
 }
예제 #3
0
 /**
  * Generate application and required vendor documentation
  */
 public function actionGenerateDocs()
 {
     if ($this->confirm('Regenerate documentation files into ./docs-html', true)) {
         // array with commands
         $commands[] = 'vendor/bin/apidoc guide --interactive=0 docs web/apidocs';
         $commands[] = 'vendor/bin/apidoc api --interactive=0 --exclude=runtime/,tests/,vendor/ . web/apidocs';
         $commands[] = 'vendor/bin/apidoc guide --interactive=0 docs web/apidocs';
         foreach ($commands as $command) {
             $cmd = new Command($command);
             if ($cmd->execute()) {
                 echo $cmd->getOutput();
             } else {
                 echo $cmd->getOutput();
                 echo $cmd->getStdErr();
                 echo $cmd->getError();
             }
         }
     }
 }
예제 #4
0
 /**
  * @param $cmd
  *
  * @return mixed
  * @throws Exception
  */
 private function execute($cmd)
 {
     $command = new Command();
     $command->setCommand($cmd);
     if ($command->execute()) {
         return $command->getOutput();
     } else {
         throw new Exception($command->getError());
     }
 }
예제 #5
0
 /**
  * @param string|null $filename the filename to add as 'output' option or null if none
  * @return bool whether the command was executed successfully
  */
 public function execute($filename = null)
 {
     $this->checkExecutionStatus();
     $this->processInputFiles();
     $this->processOperation();
     $this->processOptions($filename);
     return parent::execute();
 }
예제 #6
0
 /**
  * Execute docker-compose commande
  * @codeCoverageIgnore
  * @param Command $command The command to execute.
  */
 protected function execute($command)
 {
     if ($command->execute()) {
         $output = $command->getOutput();
     } else {
         $output = $command->getError();
     }
     return array('output' => $output, 'code' => $command->getExitCode());
 }
예제 #7
0
 public function testCanProvideProcDir()
 {
     $tmpDir = sys_get_temp_dir();
     $command = new Command('pwd');
     $command->procCwd = $tmpDir;
     $this->assertFalse($command->getExecuted());
     $this->assertTrue($command->execute());
     $this->assertTrue($command->getExecuted());
     $this->assertEquals($tmpDir, $command->getOutput());
 }