aboutsummaryrefslogtreecommitdiff
path: root/bpkg/rep-info.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-info.cxx
parent80ee886ca0bd3e41434621a056125c92f31b1aea (diff)
Add support for default options files
Diffstat (limited to 'bpkg/rep-info.cxx')
-rw-r--r--bpkg/rep-info.cxx47
1 files changed, 47 insertions, 0 deletions
diff --git a/bpkg/rep-info.cxx b/bpkg/rep-info.cxx
index 0f64565..eeb93fe 100644
--- a/bpkg/rep-info.cxx
+++ b/bpkg/rep-info.cxx
@@ -374,4 +374,51 @@ namespace bpkg
return 0;
}
+
+ default_options_files
+ options_files (const char*, const rep_info_options& o, const strings&)
+ {
+ // bpkg.options
+ // bpkg-rep-info.options
+
+ // If bpkg-rep-info operates in the configuration directory, then use it
+ // as a search start directory.
+ //
+ optional<dir_path> start_dir;
+
+ // Let rep_info() complain later for invalid configuration directory.
+ //
+ try
+ {
+ dir_path d;
+
+ if (o.directory_specified ())
+ d = dir_path (o.directory ());
+ else if (exists (bpkg_dir))
+ d = current_dir;
+
+ if (!d.empty ())
+ start_dir = move (normalize (d, "configuration"));
+ }
+ catch (const invalid_path&) {}
+
+ return default_options_files {
+ {path ("bpkg.options"), path ("bpkg-rep-info.options")},
+ move (start_dir)};
+ }
+
+ rep_info_options
+ merge_options (const default_options<rep_info_options>& defs,
+ const rep_info_options& cmd)
+ {
+ return merge_default_options (
+ defs,
+ cmd,
+ [] (const default_options_entry<rep_info_options>& e,
+ const rep_info_options&)
+ {
+ if (e.options.directory_specified ())
+ fail (e.file) << "--directory|-d in default options file";
+ });
+ }
}