aboutsummaryrefslogtreecommitdiff
path: root/bdep/config.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2021-08-18 15:00:57 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2021-08-18 18:19:11 +0300
commitba8e0b9f9866b47bc61b49323e4293ba90826e80 (patch)
tree9a5f12da8767291124b139ad4ecccf328f56b446 /bdep/config.cxx
parentfeb93edb4820feceb602b1e081f782e2e0bc45bc (diff)
Add support for config-unlink sub-command
Diffstat (limited to 'bdep/config.cxx')
-rw-r--r--bdep/config.cxx47
1 files changed, 45 insertions, 2 deletions
diff --git a/bdep/config.cxx b/bdep/config.cxx
index d62ad3e..d705355 100644
--- a/bdep/config.cxx
+++ b/bdep/config.cxx
@@ -320,9 +320,10 @@ namespace bdep
for (string l; !eof (getline (is, l)); )
{
if (l.empty ())
+ {
add_conf ();
-
- if (l.compare (0, 6, "path: ") == 0)
+ }
+ else if (l.compare (0, 6, "path: ") == 0)
{
try
{
@@ -709,6 +710,47 @@ namespace bdep
}
static int
+ cmd_config_unlink (const cmd_config_options& o, cli::scanner&)
+ {
+ tracer trace ("config_unlink");
+
+ // Load project configurations.
+ //
+ configurations cfgs;
+ {
+ dir_path prj (find_project (o));
+ database db (open (prj, trace));
+
+ transaction t (db.begin ());
+
+ cfgs = find_configurations (o,
+ prj,
+ t,
+ false /* fallback_default */,
+ true /* validate */).first;
+
+ t.commit ();
+ }
+
+ if (cfgs.size () != 2)
+ fail << "two configurations must be specified for config unlink";
+
+ // Call bpkg to unlink the configuration.
+ //
+ run_bpkg (2,
+ o,
+ "cfg-unlink",
+ "-d", cfgs[0]->path,
+ cfgs[1]->path);
+
+ if (verb)
+ text << "unlinked configuration " << *cfgs[0] << " from configuration "
+ << *cfgs[1];
+
+ return 0;
+ }
+
+ static int
cmd_config_list (const cmd_config_options& o, cli::scanner&)
{
tracer trace ("config_list");
@@ -1123,6 +1165,7 @@ namespace bdep
if (c.add ()) return cmd_config_add (o, scan);
if (c.create ()) return cmd_config_create (o, scan);
if (c.link ()) return cmd_config_link (o, scan);
+ if (c.unlink ()) return cmd_config_unlink (o, scan);
if (c.list ()) return cmd_config_list (o, scan);
if (c.move ()) return cmd_config_move (o, scan);
if (c.rename ()) return cmd_config_rename (o, scan);