aboutsummaryrefslogtreecommitdiff
path: root/bdep/config.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-05-21 12:32:58 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-05-22 08:07:05 +0200
commitef36aaf7bca0c3c878400d70ca05cf5d57aac66d (patch)
tree7c0b471dd0888df8357b393ea75f248ac392cf7b /bdep/config.cxx
parent9e1330b726c5453755bcaffd1b746d5982357861 (diff)
Implement config-remove subcommand
Diffstat (limited to 'bdep/config.cxx')
-rw-r--r--bdep/config.cxx34
1 files changed, 32 insertions, 2 deletions
diff --git a/bdep/config.cxx b/bdep/config.cxx
index 796f534..8193140 100644
--- a/bdep/config.cxx
+++ b/bdep/config.cxx
@@ -287,9 +287,39 @@ namespace bdep
}
static int
- cmd_config_remove (const cmd_config_options&, cli::scanner&)
+ cmd_config_remove (const cmd_config_options& o, cli::scanner&)
{
- fail << "@@ TODO" << endf;
+ tracer trace ("config_remove");
+
+ dir_path prj (find_project (o));
+ database db (open (prj, trace));
+
+ transaction t (db.begin ());
+
+ configurations cfgs (
+ find_configurations (o,
+ prj,
+ t,
+ false /* fallback_default */,
+ false /* validate */));
+
+ for (const shared_ptr<configuration>& c: cfgs)
+ {
+ if (!c->packages.empty ())
+ fail << "configuration " << *c << " contains initialized packages" <<
+ info << "use deinit command to deinitialize packages" <<
+ info << "use status command to list initialized packages";
+
+ db.erase (c);
+ }
+
+ t.commit ();
+
+ if (verb)
+ for (const shared_ptr<configuration>& c: cfgs)
+ text << "removed configuration " << *c;
+
+ return 0;
}
static int