From ba8e0b9f9866b47bc61b49323e4293ba90826e80 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 18 Aug 2021 15:00:57 +0300 Subject: Add support for config-unlink sub-command --- bdep/config.cli | 16 +++++++++++++--- bdep/config.cxx | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 58 insertions(+), 5 deletions(-) (limited to 'bdep') diff --git a/bdep/config.cli b/bdep/config.cli index a1cdba2..17a8f41 100644 --- a/bdep/config.cli +++ b/bdep/config.cli @@ -20,6 +20,7 @@ namespace bdep \c{\b{bdep config add} \ \ \ [] [] [\b{@}] \n \b{bdep config create} [] [] [\b{@}] []\n \b{bdep config link} \ \ [] [] \n + \b{bdep config unlink} [] [] \n \b{bdep config list} \ \ [] [] [...]\n \b{bdep config move} \ \ [] [] \n \b{bdep config rename} [] [] \n @@ -113,9 +114,17 @@ namespace bdep \li|\cb{link} - The \cb{link} subcommand links one build configuration with another - by executing the \l{bpkg-cfg-link(1)} command. See - \l{bpkg-cfg-create(1)} for background on linked configurations.| + The \cb{link} subcommand links the first specified build + configuration with the second by executing the \l{bpkg-cfg-link(1)} + command. See \l{bpkg-cfg-create(1)} for background on linked + configurations.| + + \li|\cb{unlink} + + The \cb{unlink} subcommand unlinks the first specified build + configuration from the second by executing the \l{bpkg-cfg-unlink(1)} + command. See \l{bpkg-cfg-create(1)} for background on linked + configurations.| \li|\cb{list} @@ -165,6 +174,7 @@ namespace bdep bool add; bool create; bool link; + bool unlink; bool list; bool move; bool rename; 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); -- cgit v1.1