Completed
Pull Request — develop (#54)
by Steven
19:22 queued 16:17
created

RunCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 1
cbo 4
dl 0
loc 27
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 8 1
A execute() 0 8 1
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
/**
10
 * Class RunCommand
11
 * @package Magestead\Command\VM
12
 */
13
class RunCommand extends Command
14
{
15
    protected $_projectPath;
16
17
    protected function configure()
18
    {
19
        $this->_projectPath = getcwd();
20
21
        $this->setName("vm:run");
22
        $this->setDescription("Run commands on your development machine via SSH");
23
        $this->addArgument('ssh-command', InputArgument::REQUIRED, 'The command to pass to the machine.');
24
    }
25
26
    /**
27
     * @param InputInterface $input
28
     * @param OutputInterface $output
29
     * @return ProcessCommand
30
     */
31
    protected function execute(InputInterface $input, OutputInterface $output)
32
    {
33
        $command = $input->getArgument('ssh-command');
34
        $output->writeln('<info>Running "'.$command.'" on Magestead</info>');
35
36
        $passedCommand = "vagrant ssh -c '". $command ."'";
37
        return new ProcessCommand($passedCommand, $this->_projectPath, $output);
38
    }
39
}
40