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/pkg-fetch.cxx | |
parent | 80ee886ca0bd3e41434621a056125c92f31b1aea (diff) |
Add support for default options files
Diffstat (limited to 'bpkg/pkg-fetch.cxx')
-rw-r--r-- | bpkg/pkg-fetch.cxx | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/bpkg/pkg-fetch.cxx b/bpkg/pkg-fetch.cxx index 28e2fac..b86ac85 100644 --- a/bpkg/pkg-fetch.cxx +++ b/bpkg/pkg-fetch.cxx @@ -43,8 +43,8 @@ namespace bpkg // If the archive is inside the configuration, use the relative path. // This way we can move the configuration around. // - c.complete ().normalize (); - a.complete ().normalize (); + normalize (c, "configuration"); + normalize (a, "archive"); if (a.sub (c)) a = a.leaf (c); @@ -346,4 +346,27 @@ namespace bpkg return 0; } + + pkg_fetch_options + merge_options (const default_options<pkg_fetch_options>& defs, + const pkg_fetch_options& cmd) + { + return merge_default_options ( + defs, + cmd, + [] (const default_options_entry<pkg_fetch_options>& e, + const pkg_fetch_options&) + { + const pkg_fetch_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 ("--purge|-p", o.purge ()); // Dangerous. + }); + } } |