Skip to content

Commit

Permalink
Merge e7588e7 into eedac2f
Browse files Browse the repository at this point in the history
  • Loading branch information
sideshowcoder committed Jan 3, 2023
2 parents eedac2f + e7588e7 commit 2d155f6
Showing 1 changed file with 12 additions and 25 deletions.
37 changes: 12 additions & 25 deletions src/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ protected function getDefaultInputDefinition(): InputDefinition
$definition->addOption(new InputOption('--web', null, InputOption::VALUE_OPTIONAL, 'If specified, uses web adapter, defaults to FileGetContents. Available adapters are: FileGetContents and SymfonyHttpClient'));
$definition->addOption(new InputOption('--web-path', null, InputOption::VALUE_OPTIONAL, 'If specified, used as a information for web adapter'));
$definition->addOption(new InputOption('--web-url', null, InputOption::VALUE_OPTIONAL, 'If specified, used as a information for web adapter'));
$definition->addOption(new InputOption('--web-allow-insecure', null, InputOption::VALUE_OPTIONAL, 'If specified, verify_peer and verify_host are disabled (only for SymfonyHttpClient)'));
$definition->addOption(new InputOption('--web-allow-insecure', null, InputOption::VALUE_NONE, 'If specified, verify_peer and verify_host are disabled (only for SymfonyHttpClient)'));
$definition->addOption(new InputOption('--web-basic-auth', null, InputOption::VALUE_OPTIONAL, 'If specified, used for basic authorization (only for SymfonyHttpClient)'));
$definition->addOption(new InputOption('--web-host', null, InputOption::VALUE_OPTIONAL, 'If specified, adds a Host header to web adapter request (only for SymfonyHttpClient)'));
$definition->addOption(new InputOption('--tmp-dir', '-t', InputOption::VALUE_REQUIRED, 'Temporary directory to write files to'));
Expand Down Expand Up @@ -177,8 +177,8 @@ public function buildContainer(InputInterface $input)
*/
private function parseConfiguration(InputInterface $input)
{
if ($input->hasParameterOption('--config')) {
$path = $input->getParameterOption('--config');
if ($input->getOption('config')) {
$path = $input->getOption('config');

if (!is_file($path)) {
throw new \RuntimeException("Could not read configuration file: {$path}");
Expand All @@ -187,43 +187,30 @@ private function parseConfiguration(InputInterface $input)
$this->config = Config::fromFile($path);
}

if ($input->hasParameterOption('--cli')) {
if ($input->getOption('cli')) {
$this->config['adapter'] = 'cli';
} elseif ($input->hasParameterOption('--fcgi')) {
$this->config['adapter'] = 'fastcgi';
$this->config['fastcgiChroot'] = $input->getParameterOption('--fcgi-chroot');

if (!is_null($input->getParameterOption('--fcgi'))) {
$this->config['fastcgi'] = $input->getParameterOption('--fcgi');
}
$this->config['fastcgiChroot'] = $input->getOption('fcgi-chroot') ?? $this->config['fastcgiChroot'];
$this->config['fastcgi'] = $input->getOption('fcgi') ?? $this->config['fastcgi'];
} elseif ($input->hasParameterOption('--web')) {
$this->config['adapter'] = 'web';
$this->config['webClient'] = $input->getOption('web') ?? 'FileGetContents';
$this->config['webPath'] = $input->getParameterOption('--web-path');
$this->config['webUrl'] = $input->getParameterOption('--web-url');
$this->config['webPath'] = $input->getOption('web-path') ?? $this->config['webPath'];
$this->config['webUrl'] = $input->getOption('web-url') ?? $this->config['webUrl'];

if ($this->config['webClient'] === 'SymfonyHttpClient') {
if ($input->hasParameterOption('--web-allow-insecure')) {
$this->config['webAllowInsecure'] = true;
}

if ($input->hasParameterOption('--web-basic-auth')) {
$this->config['webBasicAuth'] = $input->getParameterOption('--web-basic-auth');
}

if ($input->hasParameterOption('--web-host')) {
$this->config['webHost'] = $input->getParameterOption('--web-host');
}
$this->config['webAllowInsecure'] = $input->getOption('web-allow-insecure');
$this->config['webBasicAuth'] = $input->getOption('web-basic-auth') ?? $this->config['webBasicAuth'];
$this->config['webHost'] = $input->getOption('web-host') ?? $this->config['webHost'];
}
}

if ($this->config['adapter'] === 'web') {
$this->config['http'] = $this->buildHttpClient();
}

if ($input->hasParameterOption('--tmp-dir') || $input->hasParameterOption('-t')) {
$this->config['temp_dir'] = $input->getParameterOption('--tmp-dir') ?: $input->getParameterOption('-t');
}
$this->config['temp_dir'] = $input->getOption('tmp-dir') ?? $this->config['temp_dir'];
}

/**
Expand Down

0 comments on commit 2d155f6

Please sign in to comment.