aboutsummaryrefslogtreecommitdiff
path: root/bdep/config.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-03-24 13:29:06 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-03-24 13:29:06 +0200
commit234428e21adde0ddf60f9665edad3dcfb9fd2584 (patch)
tree28910fd2556f2c6b985762710a3319b981aa151e /bdep/config.cxx
parentefc78a6f3b0d1e0a2278ea5a7f2c502a6b4f00d0 (diff)
Implement --config-create|-C in init and new
Diffstat (limited to 'bdep/config.cxx')
-rw-r--r--bdep/config.cxx46
1 files changed, 38 insertions, 8 deletions
diff --git a/bdep/config.cxx b/bdep/config.cxx
index 12a6e61..55a1062 100644
--- a/bdep/config.cxx
+++ b/bdep/config.cxx
@@ -13,12 +13,13 @@ using namespace std;
namespace bdep
{
shared_ptr<configuration>
- cmd_config_add (const dir_path& prj,
- database& db,
- dir_path path,
- optional<string> name,
- optional<bool> def,
- optional<uint64_t> id)
+ cmd_config_add (const dir_path& prj,
+ database& db,
+ dir_path path,
+ optional<string> name,
+ optional<bool> def,
+ optional<uint64_t> id,
+ const char* what)
{
if (!exists (path))
fail << "configuration directory " << path << " does not exist";
@@ -42,7 +43,7 @@ namespace bdep
}
// Make sure the configuration path is absolute and normalized. Also
- // derive relative to project directory path is possible.
+ // derive relative to project directory path if possible.
//
path.complete ();
path.normalize ();
@@ -89,7 +90,7 @@ namespace bdep
if (verb)
{
diag_record dr (text);
- /* */ dr << "added configuration ";
+ /* */ dr << what << " configuration ";
if (r->name) dr << '@' << *r->name << ' ';
/* */ dr << r->path << " (" << *r->id;
if (r->default_) dr << ", default";
@@ -99,6 +100,35 @@ namespace bdep
return r;
}
+ shared_ptr<configuration>
+ cmd_config_create (const common_options& co,
+ const dir_path& prj,
+ database& db,
+ dir_path path,
+ cli::scanner& cfg_args,
+ optional<string> name,
+ optional<bool> def,
+ optional<uint64_t> id)
+ {
+ // Call bpkg to create the configuration.
+ //
+ {
+ strings args;
+ while (cfg_args.more ())
+ args.push_back (cfg_args.next ());
+
+ run_bpkg (co, "create", "-d", path, args);
+ }
+
+ return cmd_config_add (prj,
+ db,
+ move (path),
+ move (name),
+ def,
+ id,
+ "created");
+ }
+
int
cmd_config (const cmd_config_options& o, cli::scanner&)
{