diff --git a/src/Command/InstallCommand.php b/src/Command/InstallCommand.php index 3158216f..c4dc5805 100644 --- a/src/Command/InstallCommand.php +++ b/src/Command/InstallCommand.php @@ -67,6 +67,13 @@ protected function configure(): void $plugin = getenv('CI_BUILD_DIR') !== false ? getenv('CI_BUILD_DIR') : null; } + // Add more options mapped to environment variables. + $db_user = getenv('DB_USER') !== false ? getenv('DB_USER') : null; + $db_pass = getenv('DB_PASS') !== false ? getenv('DB_PASS') : ''; + $db_name = getenv('DB_NAME') !== false ? getenv('DB_NAME') : 'moodle'; + $db_host = getenv('DB_HOST') !== false ? getenv('DB_HOST') : 'localhost'; + $db_port = getenv('DB_PORT') !== false ? getenv('DB_PORT') : ''; + $this->setName('install') ->setDescription('Install everything required for CI testing') ->addOption('moodle', null, InputOption::VALUE_REQUIRED, 'Clone Moodle to this directory', 'moodle') @@ -75,11 +82,11 @@ protected function configure(): void ->addOption('branch', null, InputOption::VALUE_REQUIRED, 'Moodle git branch to clone, EG: MOODLE_29_STABLE', $branch) ->addOption('plugin', null, InputOption::VALUE_REQUIRED, 'Path to Moodle plugin', $plugin) ->addOption('db-type', null, InputOption::VALUE_REQUIRED, 'Database type, mysqli, pgsql or mariadb', $type) - ->addOption('db-user', null, InputOption::VALUE_REQUIRED, 'Database user') - ->addOption('db-pass', null, InputOption::VALUE_REQUIRED, 'Database pass', '') - ->addOption('db-name', null, InputOption::VALUE_REQUIRED, 'Database name', 'moodle') - ->addOption('db-host', null, InputOption::VALUE_REQUIRED, 'Database host', 'localhost') - ->addOption('db-port', null, InputOption::VALUE_REQUIRED, 'Database port', '') + ->addOption('db-user', null, InputOption::VALUE_REQUIRED, 'Database user', $db_user) + ->addOption('db-pass', null, InputOption::VALUE_REQUIRED, 'Database pass', $db_pass) + ->addOption('db-name', null, InputOption::VALUE_REQUIRED, 'Database name', $db_name) + ->addOption('db-host', null, InputOption::VALUE_REQUIRED, 'Database host', $db_host) + ->addOption('db-port', null, InputOption::VALUE_REQUIRED, 'Database port', $db_port) ->addOption('not-paths', null, InputOption::VALUE_REQUIRED, 'CSV of file paths to exclude', $paths) ->addOption('not-names', null, InputOption::VALUE_REQUIRED, 'CSV of file names to exclude', $names) ->addOption('extra-plugins', null, InputOption::VALUE_REQUIRED, 'Directory of extra plugins to install', $extra)