Completed
Push — feature/add-cli-installers ( 115549...a5e20d )
by Steven
13:21
created

RunCommand::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 2
1
<?php namespace Magestead\Command\VM;
2
3
use Magestead\Command\ProcessCommand;
4
use Symfony\Component\Console\Command\Command;
5
use Symfony\Component\Console\Input\InputArgument;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
class RunCommand extends Command
10
{
11
    protected $_projectPath;
12
13
    protected function configure()
14
    {
15
        $this->_projectPath = getcwd();
16
17
        $this->setName("vm:run");
18
        $this->setDescription("Run commands on your development machine via SSH");
19
        $this->addArgument('ssh-command', InputArgument::REQUIRED, 'The command to pass to the machine.');
20
    }
21
22
    /**
23
     * @param InputInterface $input
24
     * @param OutputInterface $output
25
     * @return ProcessCommand
26
     */
27
    protected function execute(InputInterface $input, OutputInterface $output)
28
    {
29
        $command = $input->getArgument('ssh-command');
30
        $output->writeln('<info>Running "'.$command.'" on Magestead</info>');
31
32
        $passedCommand = "vagrant ssh -c '". $command ."'";
33
        return new ProcessCommand($passedCommand, $this->_projectPath, $output);
34
    }
35
}