aboutsummaryrefslogtreecommitdiff
path: root/cli/do-install.php
diff options
context:
space:
mode:
authorGravatar Kasimir Cash <kasimir.cash@outlook.com> 2024-01-17 07:42:43 +0000
committerGravatar GitHub <noreply@github.com> 2024-01-17 08:42:43 +0100
commit6d14813840d163c76f6dc25395b0007a88b42e9d (patch)
treed01fccbd7e31f4fdccfc6649621ba1d8d75a9eef /cli/do-install.php
parent314077a457f04cc2f0472e036af029e2676fbf02 (diff)
Standardise command line option parsing (#6036)
* Separates long & short options for parsing * Adds parsing for short options + doc rewrites * Fixes undefined constant in check.translation * Standardises CL option parsing * Refactors option parsing * Renames getLongOptions -> getOptions * Removes unused code * Converges on string typing for options * Updates docs & help files * Updates array syntax array( ) -> [ ]
Diffstat (limited to 'cli/do-install.php')
-rwxr-xr-xcli/do-install.php24
1 files changed, 13 insertions, 11 deletions
diff --git a/cli/do-install.php b/cli/do-install.php
index 3e9c59162..2d73c2e98 100755
--- a/cli/do-install.php
+++ b/cli/do-install.php
@@ -7,8 +7,8 @@ if (file_exists(DATA_PATH . '/applied_migrations.txt')) {
fail('FreshRSS seems to be already installed!' . "\n" . 'Please use `./cli/reconfigure.php` instead.', EXIT_CODE_ALREADY_EXISTS);
}
-$parameters = array(
- 'valid' => array(
+$parameters = [
+ 'long' => [
'environment' => ':',
'base-url' => ':',
'language' => ':',
@@ -26,8 +26,9 @@ $parameters = array(
'db-password' => ':',
'db-base' => ':',
'db-prefix' => '::',
- ),
- 'deprecated' => array(
+ ],
+ 'short' => [],
+ 'deprecated' => [
'base-url' => 'base_url',
'default-user' => 'default_user',
'allow-anonymous' => 'allow_anonymous',
@@ -36,10 +37,10 @@ $parameters = array(
'api-enabled' => 'api_enabled',
'allow-robots' => 'allow_robots',
'disable-update' => 'disable_update',
- ),
-);
+ ],
+];
-$configParams = array(
+$configParams = [
'environment' => 'environment',
'base-url' => 'base_url',
'language' => 'language',
@@ -51,16 +52,16 @@ $configParams = array(
'api-enabled' => 'api_enabled',
'allow-robots' => 'allow_robots',
'disable-update' => 'disable_update',
-);
+];
-$dBconfigParams = array(
+$dBconfigParams = [
'db-type' => 'type',
'db-host' => 'host',
'db-user' => 'user',
'db-password' => 'password',
'db-base' => 'base',
'db-prefix' => 'prefix',
-);
+];
$options = parseCliParams($parameters);
@@ -89,7 +90,8 @@ if (file_exists($customConfigPath)) {
foreach ($configParams as $param => $configParam) {
if (isset($options['valid'][$param])) {
- $config[$configParam] = $options['valid'][$param];
+ $isFlag = $parameters['long'][$param] === '';
+ $config[$configParam] = $isFlag ? true : $options['valid'][$param];
}
}