Browse Source

Accept --default-config option to search and load default configuration files, even if user is specifying their own

Luke Dashjr 11 years ago
parent
commit
bcc61e98c8
2 changed files with 11 additions and 2 deletions
  1. 2 0
      README
  2. 9 2
      miner.c

+ 2 - 0
README

@@ -307,6 +307,8 @@ Options for both config file and command line:
 Options for command line only:
 Options for command line only:
 --config|-c <arg>   Load a JSON-format configuration file
 --config|-c <arg>   Load a JSON-format configuration file
 See example.conf for an example configuration.
 See example.conf for an example configuration.
+--no-default-config Inhibit loading default config file
+--default-config    Always load the default config file
 --help|-h           Print this message
 --help|-h           Print this message
 --version|-V        Display version and exit
 --version|-V        Display version and exit
 
 

+ 9 - 2
miner.c

@@ -2624,10 +2624,11 @@ static char *opt_verusage_and_exit(const char *extra)
 
 
 /* These options are parsed before anything else */
 /* These options are parsed before anything else */
 static struct opt_table opt_early_table[] = {
 static struct opt_table opt_early_table[] = {
-	OPT_EARLY_WITH_ARG("--config|-c",
+	// Default config is loaded in command line order, like a regular config
+	OPT_EARLY_WITH_ARG("--config|-c|--default-config",
 	                   set_bool_ignore_arg, NULL, &config_loaded,
 	                   set_bool_ignore_arg, NULL, &config_loaded,
 	                   opt_hidden),
 	                   opt_hidden),
-	OPT_EARLY_WITHOUT_ARG("--no-config",
+	OPT_EARLY_WITHOUT_ARG("--no-config|--no-default-config",
 	                opt_set_bool, &config_loaded,
 	                opt_set_bool, &config_loaded,
 	                "Inhibit loading default config file"),
 	                "Inhibit loading default config file"),
 	OPT_ENDTABLE
 	OPT_ENDTABLE
@@ -2640,8 +2641,14 @@ static struct opt_table opt_cmdline_table[] = {
 		     "Load a JSON-format configuration file\n"
 		     "Load a JSON-format configuration file\n"
 		     "See example.conf for an example configuration."),
 		     "See example.conf for an example configuration."),
 	OPT_EARLY_WITHOUT_ARG("--no-config",
 	OPT_EARLY_WITHOUT_ARG("--no-config",
+	                opt_set_bool, &config_loaded,
+	                opt_hidden),
+	OPT_EARLY_WITHOUT_ARG("--no-default-config",
 	                opt_set_bool, &config_loaded,
 	                opt_set_bool, &config_loaded,
 	                "Inhibit loading default config file"),
 	                "Inhibit loading default config file"),
+	OPT_WITHOUT_ARG("--default-config",
+	                load_default_config, NULL,
+	                "Always load the default config file"),
 	OPT_WITHOUT_ARG("--help|-h",
 	OPT_WITHOUT_ARG("--help|-h",
 			opt_verusage_and_exit, NULL,
 			opt_verusage_and_exit, NULL,
 			"Print this message"),
 			"Print this message"),