aboutsummaryrefslogtreecommitdiff
path: root/bdep/project.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/project.cxx
parent9e1330b726c5453755bcaffd1b746d5982357861 (diff)
Implement config-remove subcommand
Diffstat (limited to 'bdep/project.cxx')
-rw-r--r--bdep/project.cxx33
1 files changed, 23 insertions, 10 deletions
diff --git a/bdep/project.cxx b/bdep/project.cxx
index b3b76b3..dacb921 100644
--- a/bdep/project.cxx
+++ b/bdep/project.cxx
@@ -15,9 +15,11 @@ using namespace std;
namespace bdep
{
configurations
- find_configurations (const dir_path& prj,
+ find_configurations (const project_options& po,
+ const dir_path& prj,
transaction& t,
- const project_options& po)
+ bool fallback_default,
+ bool validate)
{
configurations r;
@@ -85,26 +87,37 @@ namespace bdep
{
for (auto c: pointer_result (db.query<configuration> ()))
add (c);
+
+ if (r.empty ())
+ fail << "no existing configurations";
}
// default
//
if (r.empty ())
{
- if (auto c = db.query_one<configuration> (query::default_))
- add (c);
+ if (fallback_default)
+ {
+ if (auto c = db.query_one<configuration> (query::default_))
+ add (c);
+ else
+ fail << "no default configuration in project " << prj <<
+ info << "use (@<cfg-name> | --config|-c <cfg-dir> | --all|-a) to "
+ << "specify configuration explicitly";
+ }
else
- fail << "no default configuration in project " << prj <<
- info << "use (@<cfg-name> | --config|-c <cfg-dir> | --all|-a) to "
- << "specify configuration explicitly";
+ fail << "no configurations specified";
}
// Validate all the returned configuration directories are still there.
//
- for (const shared_ptr<configuration>& c: r)
+ if (validate)
{
- if (!exists (c->path))
- fail << "configuration directory " << c->path << " no longer exists";
+ for (const shared_ptr<configuration>& c: r)
+ {
+ if (!exists (c->path))
+ fail << "configuration directory " << c->path << " no longer exists";
+ }
}
return r;