Skip to content

Commit

Permalink
Making app add command non-interactive.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonpugh committed May 19, 2015
1 parent 1e037a6 commit a9a9640
Showing 1 changed file with 46 additions and 19 deletions.
65 changes: 46 additions & 19 deletions src/Director/Command/AppAddCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 29,28 @@ protected function configure()
$this
->setName('app:add')
->setDescription('Adds a new app.')
->addArgument(
'name',
InputArgument::OPTIONAL,
'The name of your app.'
)
->addArgument(
'repo',
InputArgument::OPTIONAL,
'The URL of your git repo for your app.'
)
->addOption(
'description',
'',
InputArgument::OPTIONAL,
'The name of your app.'
)
->addOption(
'create-environment',
'',
InputArgument::OPTIONAL,
'Whether or not to create an environment.'
)
;
}

Expand All @@ -37,16 59,25 @@ protected function execute(InputInterface $input, OutputInterface $output)
$helper = $this->getHelper('question');

// App Name
$question = new Question('System name of your project? ', '');
$name = $helper->ask($input, $output, $question);
$name = $input->getArgument('name');
if (empty($name)) {
$question = new Question('System name of your project? ', '');
$name = $helper->ask($input, $output, $question);
}

// App Description
$question = new Question('Description? ', '');
$description = $helper->ask($input, $output, $question);
$description = $input->getOption('description');
if (empty($description)) {
$question = new Question('Description? ', '');
$description = $helper->ask($input, $output, $question);
}

// App Source
$question = new Question('Source code repository URL? ', '');
$repo = $helper->ask($input, $output, $question);
$repo = $input->getArgument('repo');
if (empty($repo)) {
$question = new Question('Source code repository URL? ', '');
$repo = $helper->ask($input, $output, $question);
}

$app = new App($name, $repo, $description);
$this->director->config['apps'][$name] = (array) $app;
Expand All @@ -57,20 88,16 @@ protected function execute(InputInterface $input, OutputInterface $output)

// Confirmation
$question = new ConfirmationQuestion("Create an environment? ", false);
if (!$helper->ask($input, $output, $question)) {
return;
}
if ( $input->getOption('create-environment') || $helper->ask($input, $output, $question)) {
// Run environment:add command.
$command = $this->getApplication()->find('environment:add');

// Run environment:add command.
$command = $this->getApplication()->find('environment:add');

$arguments = array(
// 'command' => 'demo:greet',
'app' => $name,
);

$input = new ArrayInput($arguments);
$command->run($input, $output);
$arguments = array(
'app' => $name,
);

$input = new ArrayInput($arguments);
$command->run($input, $output);
}
}
}

0 comments on commit a9a9640

Please sign in to comment.