Attempts to load a configuration given a file or default files and overrides with command line arguments @return A config object with user settings or defaults @throws IOException If there was an error opening any of the config files @throws FileNotFoundException If the user provided config file was
(final ArgP argp)
| 92 | * @since 2.0 |
| 93 | */ |
| 94 | static final Config getConfig(final ArgP argp) throws IOException { |
| 95 | // load configuration |
| 96 | final Config config; |
| 97 | final String config_file = argp.get("--config", ""); |
| 98 | if (!config_file.isEmpty()) |
| 99 | config = new Config(config_file); |
| 100 | else |
| 101 | config = new Config(true); |
| 102 | |
| 103 | // load CLI overloads |
| 104 | overloadConfig(argp, config); |
| 105 | // the auto metric is recorded to a class boolean flag since it's used so |
| 106 | // often. We have to set it manually after overriding. |
| 107 | config.setAutoMetric(config.getBoolean("tsd.core.auto_create_metrics")); |
| 108 | return config; |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * Copies the parsed command line options to the {@link Config} class |
no test coverage detected