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

Change the default behavior of selecting default configurations #346

Merged
merged 2 commits into from May 31, 2021
Merged

Change the default behavior of selecting default configurations #346

merged 2 commits into from May 31, 2021

Conversation

ghost
Copy link

@ghost ghost commented May 26, 2021

Hi everyone,

I noticed that current init process requires an explicit parameter to use YAML config.

Therefore, to allow usage of YAML as default config, here is my proposal on this section that:

When user has explicitly specified a config using -config parameter:

  1. check whether it is a JSON or YAML file. If it is not JSON nor YAML, raise a fatal exception (line 34);
  2. read file. If it does not exist or something wrong happened during reading, raise a fatal exception (line 39-45);
  3. build a proxy based on it. If it is not valid, raise a fatal exception (line 51);
  4. run the proxy. If something happened, raise a fatal exception (line 55);
  5. if nothing wrong happened, return nil marking successful reading and parsing.

When user has not explicitly specified:

My proposal will try three candidate: config.json, config.yml, and config.yaml.

For each candidate:

  1. 1 is definitely passing;
  2. read file. If the file does not exist (indicated by err.Error()), raise a warning that the file is not there and move to next candidate (line 40-42 and line 78); if anything else happened, raise a fatal exception is raised (line 44);
  3. 3, 4, and 5 are the same.
  4. If all three candidates cannot be loaded, raise a fatal exception (line 82) showing that no default candidate is provided.

There is one thing to do: I have no idea what OS X raise when a file is not found.

I am looking forward to your ideas and feedback.

Regards,
Chinese White Dolphin

@Loyalsoldier Loyalsoldier merged commit d538823 into p4gefau1t:master May 31, 2021
@Loyalsoldier
Copy link
Collaborator

Thanks! I have made some refinements.

@ghost ghost deleted the patch-2 branch May 31, 2021 10:18
@ghost
Copy link
Author

ghost commented May 31, 2021

It is me to say thank you. It is an overhaul :-D.

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.

1 participant