diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2019-08-14 14:36:44 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2019-08-16 14:53:54 +0300 |
commit | ed437dbd3483baa3d15d1d86d8f057d9112653b1 (patch) | |
tree | cbf3974e8b1774ccccd818442cf042e501190b09 /bpkg/cfg-create.cxx | |
parent | 80ee886ca0bd3e41434621a056125c92f31b1aea (diff) |
Add support for default options files
Diffstat (limited to 'bpkg/cfg-create.cxx')
-rw-r--r-- | bpkg/cfg-create.cxx | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/bpkg/cfg-create.cxx b/bpkg/cfg-create.cxx index 14fb982..1bc1a57 100644 --- a/bpkg/cfg-create.cxx +++ b/bpkg/cfg-create.cxx @@ -161,7 +161,8 @@ namespace bpkg if (verb && !o.no_result ()) { - c.complete ().normalize (); + normalize (c, "configuration"); + if (o.existing ()) text << "initialized existing configuration in " << c; else @@ -170,4 +171,49 @@ namespace bpkg return 0; } + + default_options_files + options_files (const char*, const cfg_create_options& o, const strings&) + { + // bpkg.options + // bpkg-cfg-create.options + + // Use the configuration parent directory as a start directory. + // + optional<dir_path> start_dir; + + // Let cfg_create() complain later for the root directory used as a + // configuration directory. + // + dir_path d (normalize (o.directory (), "configuration")); + if (!d.root ()) + start_dir = d.directory (); + + return default_options_files { + {path ("bpkg.options"), path ("bpkg-cfg-create.options")}, + move (start_dir)}; + } + + cfg_create_options + merge_options (const default_options<cfg_create_options>& defs, + const cfg_create_options& cmd) + { + return merge_default_options ( + defs, + cmd, + [] (const default_options_entry<cfg_create_options>& e, + const cfg_create_options&) + { + const cfg_create_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 ("--wipe", o.wipe ()); // Dangerous. + }); + } } |