aboutsummaryrefslogtreecommitdiff
path: root/bpkg/rep-create.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2019-08-14 14:36:44 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2019-08-16 14:53:54 +0300
commited437dbd3483baa3d15d1d86d8f057d9112653b1 (patch)
treecbf3974e8b1774ccccd818442cf042e501190b09 /bpkg/rep-create.cxx
parent80ee886ca0bd3e41434621a056125c92f31b1aea (diff)
Add support for default options files
Diffstat (limited to 'bpkg/rep-create.cxx')
-rw-r--r--bpkg/rep-create.cxx45
1 files changed, 43 insertions, 2 deletions
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<dir_path> 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<rep_create_options>& defs,
+ const rep_create_options& cmd)
+ {
+ return merge_default_options (
+ defs,
+ cmd,
+ [] (const default_options_entry<rep_create_options>& e,
+ const rep_create_options&)
+ {
+ // For security reason.
+ //
+ if (e.options.key_specified () && e.remote)
+ fail (e.file) << "--key <name> in remote default options file";
+ });
+ }
}