diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2019-08-12 14:56:03 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2019-08-13 16:52:16 +0300 |
commit | edab35e216bc3839915129e54f98160428634283 (patch) | |
tree | 51c1ae471e39aca817038f16d33cc25be4998369 /bdep/sync.cxx | |
parent | 54c937f78562fc6a5d2ea01c8747c62ccea980cb (diff) |
Add support for default options files
Diffstat (limited to 'bdep/sync.cxx')
-rw-r--r-- | bdep/sync.cxx | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/bdep/sync.cxx b/bdep/sync.cxx index cb85e98..ab2fb2b 100644 --- a/bdep/sync.cxx +++ b/bdep/sync.cxx @@ -861,4 +861,59 @@ namespace bdep return 0; } + + default_options_files + options_files (const char*, const cmd_sync_options& o, const strings&) + { + // bdep.options + // bdep-{sync|sync-implicit}.options + + default_options_files r {{path ("bdep.options")}, nullopt}; + + // Add bdep-sync-implicit.options for an implicit sync and + // bdep-sync.options otherwise. Omit the search start dir in the former + // case. + // + auto add = [&r] (const string& n) + { + r.files.push_back (path ("bdep-" + n + ".options")); + }; + + if (o.implicit () || o.hook_specified ()) + { + add ("sync-implicit"); + } + else + { + add ("sync"); + + r.start_dir = find_project (o); + } + + return r; + } + + cmd_sync_options + merge_options (const default_options<cmd_sync_options>& defs, + const cmd_sync_options& cmd) + { + return merge_default_options ( + defs, + cmd, + [] (const default_options_entry<cmd_sync_options>& e, + const cmd_sync_options&) + { + const cmd_sync_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 ("--implicit", o.implicit ()); + forbid ("--hook", o.hook_specified ()); + }); + } } |