Skip to content

Commit 86bfe17

Browse files
committed
Split option --install-provisional-version into two commands. --install-provisional-version becomes a bool and new option --provisional-version accepts a string.
1 parent 7a77023 commit 86bfe17

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

src/Smrtr/MysqlVersionControl/UpCommand.php

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,15 @@ protected function configure()
5757
->addOption(
5858
'install-provisional-version',
5959
null,
60-
InputOption::VALUE_OPTIONAL,
61-
'Install a provisional version which may still be in development and is not final. '.PHP_EOL.
62-
'The provisional version is in a dir named \''.self::DEFAULT_PROVISIONAL_VERSION_NAME.'\' by default; '.
63-
PHP_EOL.'provide a value for this option to override the dirname.'
60+
InputOption::VALUE_NONE,
61+
'Install a provisional version which may still be in development and is not final.'
62+
)
63+
->addOption(
64+
'provisional-version',
65+
null,
66+
InputOption::VALUE_REQUIRED,
67+
'The name of the provisional version',
68+
static::DEFAULT_PROVISIONAL_VERSION_NAME
6469
)
6570
;
6671
}
@@ -99,7 +104,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
99104
$output->writeln('Installing version control...');
100105

101106
$result = $buildConf->prepare(
102-
"CREATE TABLE `db_config`
107+
"CREATE TABLE `db_config`
103108
(
104109
`key` VARCHAR(50) COLLATE 'utf8_general_ci' NOT NULL,
105110
`value` TEXT,
@@ -182,20 +187,17 @@ protected function execute(InputInterface $input, OutputInterface $output)
182187
}
183188

184189
// Look for a provisional version?
185-
$provisionalVersion = $input->getOption('install-provisional-version');
186-
if ($provisionalVersion) {
187-
188-
if (!is_string($provisionalVersion)) {
189-
$provisionalVersion = self::DEFAULT_PROVISIONAL_VERSION_NAME;
190-
}
190+
$provisionalVersion = null;
191+
if ($input->getOption('install-provisional-version')) {
191192

193+
$provisionalVersion = $input->getOption('provisional-version');
192194
$output->writeln('Provisional version: '.$provisionalVersion);
193195

194196
$path = $versionsPath.DIRECTORY_SEPARATOR.$provisionalVersion;
195197
if (is_readable($path) && is_dir($path)) {
196198

197199
foreach ($filesToLookFor as $file) {
198-
if (is_readable($file.DIRECTORY_SEPARATOR.$file) && is_file($path.DIRECTORY_SEPARATOR.$file)) {
200+
if (is_readable($path.DIRECTORY_SEPARATOR.$file) && is_file($path.DIRECTORY_SEPARATOR.$file)) {
199201
$stack[$provisionalVersion][$file] = $path.DIRECTORY_SEPARATOR.$file;
200202
}
201203
}
@@ -275,7 +277,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
275277
}
276278
}
277279

278-
if ($result) {
280+
if ($result && is_int($version)) {
279281
$result = $buildConf->query(
280282
"REPLACE INTO `db_config` (`key`, `value`, `updated_at`) VALUES ('version', $version, now())"
281283
)->execute();

0 commit comments

Comments
 (0)