Status.php
1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
// +----------------------------------------------------------------------
// | TopThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015 http://www.topthink.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: zhangyajun <448901948@qq.com>
// +----------------------------------------------------------------------
namespace think\migration\command\migrate;
use think\migration\command\AbstractCommand;
use think\console\input\Option as InputOption;
use think\console\Input;
use think\console\Output;
class Status extends AbstractCommand
{
/**
* {@inheritdoc}
*/
protected function configure()
{
parent::configure();
$this->setName('migrate:status')
->setDescription('Show migration status')
->addOption('--format', '-f', InputOption::VALUE_REQUIRED, 'The output format: text or json. Defaults to text.')
->setHelp(
<<<EOT
The <info>migrate:status</info> command prints a list of all migrations, along with their current status
<info>php console migrate:status</info>
<info>php console migrate:status -f json</info>
EOT
);
}
/**
* Show the migration status.
*
* @param Input $input
* @param Output $output
* @return integer 0 if all migrations are up, or an error code
*/
protected function execute(Input $input, Output $output)
{
$this->bootstrap($input, $output);
$format = $input->getOption('format');
if (null !== $format) {
$output->writeln('<info>using format</info> ' . $format);
}
// print the status
return $this->getManager()->printStatus($format);
}
}