Skip to content

Commit

Permalink
Add 'todo' option to status command
Browse files Browse the repository at this point in the history
  • Loading branch information
gggeek committed Jun 23, 2018
1 parent 0b19210 commit 54d5933
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions Command/StatusCommand.php
Expand Up @@ -24,6 +24,7 @@ protected function configure()
->setDescription('View the status of all (or a set of) migrations.')
->addOption('path', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, "The directory or file to load the migration definitions from")
->addOption('summary', null, InputOption::VALUE_NONE, "Only print summary information")
->addOption('todo', null, InputOption::VALUE_NONE, "Only print list of migrations to execute (full path to each)")
->setHelp(<<<EOT
The <info>kaliop:migration:status</info> command displays the status of all available migrations:
Expand Down Expand Up @@ -75,7 +76,7 @@ public function execute(InputInterface $input, OutputInterface $output)
}
ksort($index);

if (!$input->getOption('summary')) {
if (!$input->getOption('summary') && !$input->getOption('todo')) {
if (count($index) > 50000) {
$output->writeln("WARNING: printing the status table might take a while as it contains many rows. Please wait...");
}
Expand Down Expand Up @@ -105,13 +106,18 @@ public function execute(InputInterface $input, OutputInterface $output)
} else {
$summary[Migration::STATUS_TODO][1]++;
}
$data[] = array(
$i++,
$name,
'<error>not executed</error>',
'',
$notes
);
if ($input->getOption('todo')) {
$data[] = $migrationDefinition->path;
} else {
$data[] = array(
$i++,
$name,
'<error>not executed</error>',
'',
$notes
);

}
} else {
$migration = $value['migration'];

Expand All @@ -123,6 +129,14 @@ public function execute(InputInterface $input, OutputInterface $output)
continue;
}

if ($input->getOption('todo')) {
if ($migration->status == Migration::STATUS_TODO) {
$data[] = $migration->path;
}

continue;
}

switch ($migration->status) {
case Migration::STATUS_DONE:
$status = '<info>executed</info>';
Expand Down Expand Up @@ -173,6 +187,13 @@ public function execute(InputInterface $input, OutputInterface $output)
}
}

if ($input->getOption('todo')) {
foreach ($data as $migrationData) {
echo "$migrationData\n";
}
return;
}

if ($input->getOption('summary')) {
$output->writeln("\n <info>==</info> Migrations Summary\n");
// do not print info about the not yet supported case
Expand Down

0 comments on commit 54d5933

Please sign in to comment.