From 234428e21adde0ddf60f9665edad3dcfb9fd2584 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 24 Mar 2018 13:29:06 +0200 Subject: Implement --config-create|-C in init and new --- bdep/config.cxx | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) (limited to 'bdep/config.cxx') diff --git a/bdep/config.cxx b/bdep/config.cxx index 12a6e61..55a1062 100644 --- a/bdep/config.cxx +++ b/bdep/config.cxx @@ -13,12 +13,13 @@ using namespace std; namespace bdep { shared_ptr - cmd_config_add (const dir_path& prj, - database& db, - dir_path path, - optional name, - optional def, - optional id) + cmd_config_add (const dir_path& prj, + database& db, + dir_path path, + optional name, + optional def, + optional id, + const char* what) { if (!exists (path)) fail << "configuration directory " << path << " does not exist"; @@ -42,7 +43,7 @@ namespace bdep } // Make sure the configuration path is absolute and normalized. Also - // derive relative to project directory path is possible. + // derive relative to project directory path if possible. // path.complete (); path.normalize (); @@ -89,7 +90,7 @@ namespace bdep if (verb) { diag_record dr (text); - /* */ dr << "added configuration "; + /* */ dr << what << " configuration "; if (r->name) dr << '@' << *r->name << ' '; /* */ dr << r->path << " (" << *r->id; if (r->default_) dr << ", default"; @@ -99,6 +100,35 @@ namespace bdep return r; } + shared_ptr + cmd_config_create (const common_options& co, + const dir_path& prj, + database& db, + dir_path path, + cli::scanner& cfg_args, + optional name, + optional def, + optional id) + { + // Call bpkg to create the configuration. + // + { + strings args; + while (cfg_args.more ()) + args.push_back (cfg_args.next ()); + + run_bpkg (co, "create", "-d", path, args); + } + + return cmd_config_add (prj, + db, + move (path), + move (name), + def, + id, + "created"); + } + int cmd_config (const cmd_config_options& o, cli::scanner&) { -- cgit v1.1