From ed437dbd3483baa3d15d1d86d8f057d9112653b1 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 14 Aug 2019 14:36:44 +0300 Subject: Add support for default options files --- bpkg/rep-create.cxx | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'bpkg/rep-create.cxx') diff --git a/bpkg/rep-create.cxx b/bpkg/rep-create.cxx index f9d239b..f0df1c0 100644 --- a/bpkg/rep-create.cxx +++ b/bpkg/rep-create.cxx @@ -246,8 +246,7 @@ namespace bpkg if (verb && !o.no_result ()) { - d.complete (); - d.normalize (); + normalize (d, "repository"); text << pm.size () << " package(s) in " << d; } @@ -257,4 +256,46 @@ namespace bpkg { fail << "invalid path: '" << e.path << "'" << endf; } + + default_options_files + options_files (const char*, const rep_create_options&, const strings& args) + { + // bpkg.options + // bpkg-rep-create.options + + // Use the repository directory as a start directory. + // + optional start_dir; + + // Let rep_create() complain later for invalid repository directory. + // + try + { + dir_path d (!args.empty () ? args[0] : "."); + if (!d.empty ()) + start_dir = move (normalize (d, "repository")); + } + catch (const invalid_path&) {} + + return default_options_files { + {path ("bpkg.options"), path ("bpkg-rep-create.options")}, + move (start_dir)}; + } + + rep_create_options + merge_options (const default_options& defs, + const rep_create_options& cmd) + { + return merge_default_options ( + defs, + cmd, + [] (const default_options_entry& e, + const rep_create_options&) + { + // For security reason. + // + if (e.options.key_specified () && e.remote) + fail (e.file) << "--key in remote default options file"; + }); + } } -- cgit v1.1