Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor parse configuration #223

Merged

Conversation

sideshowcoder
Copy link
Contributor

  • Using parsed valued via getOption where possible
  • Merge flags with preset value consistently
  • Use VALUE_NONE for option --web-allow-insecure which does not allow for a value to be set.

Use `getOption` to get the parsed value from the `--config` flag passed.
Using `getOption` on `VALUE_NONE` with either return `true` if set, or `false`
if not set.
flags passed via arguments take precedence, but fallback to config file options,
or defaults when not passed.
The config is either `true` or `false` which is same as `VALUE_NONE`.
if provided use the option passed otherwise use what is already set in config.
the parsed value with always be set under `tmp-dir` removing the requirement
for reading the short option `-t` as well as long `--tmp-dir`. Fall back to
config provided unless set.
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'];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the parsed option will always yield the result under tmp-dir no need to check the short hand as well.

if ($input->hasParameterOption('--web-host')) {
$this->config['webHost'] = $input->getParameterOption('--web-host');
}
$this->config['webAllowInsecure'] = $input->getOption('web-allow-insecure');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure how to merge this here, I think this is a bit tricky since not providing it should set it to false, while providing it means true, no matter what the previous config value is. I don't think this is an issue so as previously this was not merged with the config from file either.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think its an issue as well.

@gordalina gordalina merged commit 8e341f6 into gordalina:main Jan 3, 2023
@gordalina
Copy link
Owner

Thank you!

@gordalina
Copy link
Owner

Released in 9.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants