aboutsummaryrefslogtreecommitdiff
path: root/bdep/config.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-05-14 14:00:14 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-05-14 14:00:14 +0200
commita2e7f2beb522d9c7cda01ecfcb552d8e0c46b088 (patch)
tree41a18eca91fb9a6bdaa9f268cb30582a271f4ef5 /bdep/config.cxx
parent9761746f14c81ba0dbd023d31f0e4662c12da66b (diff)
Implement shortcut config add/create versions
Now: $ bdep init -C ../hello-clang @clang ... Can be rewritten as: $ bdep init -C @clang ...
Diffstat (limited to 'bdep/config.cxx')
-rw-r--r--bdep/config.cxx25
1 files changed, 25 insertions, 0 deletions
diff --git a/bdep/config.cxx b/bdep/config.cxx
index 45cba1f..28289fb 100644
--- a/bdep/config.cxx
+++ b/bdep/config.cxx
@@ -12,6 +12,27 @@ using namespace std;
namespace bdep
{
+ // Translate the configuration directory that is actually a name (@foo) to
+ // the real directory (prj-foo) and name (@foo).
+ //
+ static inline void
+ translate_path_name (const dir_path& prj,
+ dir_path& path,
+ optional<string> name)
+ {
+ if (name || !path.simple () || path.string ().front () != '@')
+ return;
+
+ string n (move (path).string ()); // Move out.
+ n.erase (0, 1); // Remove leading '@'.
+
+ path = prj;
+ path += '-';
+ path += n;
+
+ name = move (n);
+ }
+
shared_ptr<configuration>
cmd_config_add (const configuration_add_options& ao,
const dir_path& prj,
@@ -21,6 +42,8 @@ namespace bdep
optional<uint64_t> id,
const char* what)
{
+ translate_path_name (prj, path, name);
+
if (!exists (path))
fail << "configuration directory " << path << " does not exist";
@@ -142,6 +165,8 @@ namespace bdep
optional<string> name,
optional<uint64_t> id)
{
+ translate_path_name (prj, path, name);
+
// Call bpkg to create the configuration.
//
{