aboutsummaryrefslogtreecommitdiff
path: root/bdep/init.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2019-08-12 14:56:03 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2019-08-13 16:52:16 +0300
commitedab35e216bc3839915129e54f98160428634283 (patch)
tree51c1ae471e39aca817038f16d33cc25be4998369 /bdep/init.cxx
parent54c937f78562fc6a5d2ea01c8747c62ccea980cb (diff)
Add support for default options files
Diffstat (limited to 'bdep/init.cxx')
-rw-r--r--bdep/init.cxx54
1 files changed, 54 insertions, 0 deletions
diff --git a/bdep/init.cxx b/bdep/init.cxx
index 30cabb2..e6ddc1e 100644
--- a/bdep/init.cxx
+++ b/bdep/init.cxx
@@ -233,4 +233,58 @@ namespace bdep
return 0;
}
+
+ default_options_files
+ options_files (const char*, const cmd_init_options& o, const strings&)
+ {
+ // bdep.options
+ // bdep-{config config-add}.options # -A
+ // bdep-{config config-add config-create}.options # -C
+ // bdep-init.options
+
+ default_options_files r {{path ("bdep.options")}, find_project (o)};
+
+ auto add = [&r] (const string& n)
+ {
+ r.files.push_back (path ("bdep-" + n + ".options"));
+ };
+
+ if (o.config_add_specified () || o.config_create_specified ())
+ {
+ add ("config");
+ add ("config-add");
+ }
+
+ if (o.config_create_specified ())
+ add ("config-create");
+
+ add ("init");
+
+ return r;
+ }
+
+ cmd_init_options
+ merge_options (const default_options<cmd_init_options>& defs,
+ const cmd_init_options& cmd)
+ {
+ return merge_default_options (
+ defs,
+ cmd,
+ [] (const default_options_entry<cmd_init_options>& e,
+ const cmd_init_options&)
+ {
+ const cmd_init_options& o (e.options);
+
+ auto forbid = [&e] (const char* opt, bool specified)
+ {
+ if (specified)
+ fail (e.file) << opt << " in default options file";
+ };
+
+ forbid ("--directory|-d", o.directory_specified ());
+ forbid ("--config-add|-A", o.config_add_specified ());
+ forbid ("--config-create|-C", o.config_create_specified ());
+ forbid ("--wipe", o.wipe ()); // Dangerous.
+ });
+ }
}