diff options
-rw-r--r-- | bdep/bdep.cxx | 19 | ||||
-rw-r--r-- | bdep/buildfile | 2 | ||||
-rw-r--r-- | bdep/config.cli | 17 | ||||
-rw-r--r-- | bdep/config.cxx | 46 | ||||
-rw-r--r-- | bdep/config.hxx | 15 | ||||
-rw-r--r-- | bdep/init.cli | 4 | ||||
-rw-r--r-- | bdep/init.cxx | 16 | ||||
-rw-r--r-- | bdep/init.hxx | 1 | ||||
-rw-r--r-- | bdep/new-types.hxx | 4 | ||||
-rw-r--r-- | bdep/new.cli | 8 | ||||
-rw-r--r-- | bdep/new.cxx | 1 |
11 files changed, 89 insertions, 44 deletions
diff --git a/bdep/bdep.cxx b/bdep/bdep.cxx index 05fcc47..1f9c2ca 100644 --- a/bdep/bdep.cxx +++ b/bdep/bdep.cxx @@ -49,6 +49,7 @@ cfg_name (configuration_name_options* o, const char* a) fail << "empty configuration name"; o->config_name ().push_back (move (n)); + o->config_name_specified (true); return true; } @@ -72,32 +73,30 @@ init (const common_options& co, cli::scanner& scan, strings& args) { if (opt) { + const char* a (scan.peek ()); + // If we see first "--", then we are done parsing options. // - if (strcmp (scan.peek (), "--") == 0) + if (strcmp (a, "--") == 0) { scan.next (); opt = false; continue; } - // Parse the next chunk of options until we reach an argument (or eos). - // - o.parse (scan); - - if (!scan.more ()) - break; - // @<cfg-name> // - const char* a (scan.peek ()); - if (*a == '@' && cfg_name (&o, a + 1)) { scan.next (); continue; } + // Parse the next chunk of options until we reach an argument (or eos). + // + if (o.parse (scan)) + continue; + // Fall through. } diff --git a/bdep/buildfile b/bdep/buildfile index ac355e4..1a4fd60 100644 --- a/bdep/buildfile +++ b/bdep/buildfile @@ -74,7 +74,7 @@ if $cli.configured cli.options += -I $src_root --include-with-brackets --include-prefix bdep \ --guard-prefix BDEP --cxx-prologue "#include <bdep/types-parsers.hxx>" \ --cli-namespace bdep::cli --generate-vector-scanner --generate-file-scanner \ ---generate-specifier --generate-modifier --generate-parse \ +--keep-separator --generate-specifier --generate-modifier --generate-parse \ --page-usage 'bdep::print_$name$_' --ansi-color --include-base-last \ --suppress-undocumented --option-length 23 diff --git a/bdep/config.cli b/bdep/config.cli index 30f7ed7..37f7ae2 100644 --- a/bdep/config.cli +++ b/bdep/config.cli @@ -14,8 +14,16 @@ namespace bdep "<options> <cfg-spec> <cfg-name> <cfg-dir> <prj-spec> <prj-dir> - <cfg-args> <cfg-var> <module>", + <cfg-args> <option> <module> <cfg-var>", + // Other potential subcommands: + // + // list - list associated configurations + // show|status - details about a configuration (init'ed packages, etc) + // + // @@ Should we be able to remove config with init'ed packages? Who + // is going to drop them in configs? Or require them to be de-init'ed? + // "\h|SYNOPSIS| \c{\b{bdep config add} \ \ \ [<options>] [<prj-spec>] [\b{@}<cfg-name>] <cfg-dir>\n @@ -26,16 +34,15 @@ namespace bdep \c{<cfg-spec> = \b{@}<cfg-name> | \b{--config}|\b{-c} <cfg-dir>\n <prj-spec> = \b{--directory}|\b{-d} <prj-dir>\n - <cfg-args> = (<module> | <cfg-var>)...} + <cfg-args> = (<option> | <module> | <cfg-var>)...} \h|DESCRIPTION| The \cb{config} command... - Unless the \cb{--no-default} option is specified, the first added or - created build configuration is designated as the default configuration. - Several \cb{bdep} commands use such a configuration by default if no + created build configuration is designated as the default. Several + \cb{bdep} commands use such a configuration by default if no configuration was specified explicitly (see \l{bdep-projects-configs(1)} for details). To make a subsequently added configuration the default use the \cb{--default} option. 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<configuration> - cmd_config_add (const dir_path& prj, - database& db, - dir_path path, - optional<string> name, - optional<bool> def, - optional<uint64_t> id) + cmd_config_add (const dir_path& prj, + database& db, + dir_path path, + optional<string> name, + optional<bool> def, + optional<uint64_t> 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<configuration> + cmd_config_create (const common_options& co, + const dir_path& prj, + database& db, + dir_path path, + cli::scanner& cfg_args, + optional<string> name, + optional<bool> def, + optional<uint64_t> 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&) { diff --git a/bdep/config.hxx b/bdep/config.hxx index 2f04719..2ebda45 100644 --- a/bdep/config.hxx +++ b/bdep/config.hxx @@ -14,12 +14,23 @@ namespace bdep { shared_ptr<configuration> - cmd_config_add (const dir_path& prj, + cmd_config_add (const dir_path& prj, database&, dir_path path, optional<string> name, optional<bool> default_ = nullopt, - optional<uint64_t> id = nullopt); + optional<uint64_t> id = nullopt, + const char* what = "added"); + + shared_ptr<configuration> + cmd_config_create (const common_options&, + const dir_path& prj, + database&, + dir_path path, + cli::scanner& args, + optional<string> name, + optional<bool> default_ = nullopt, + optional<uint64_t> id = nullopt); int cmd_config (const cmd_config_options&, cli::scanner& args); diff --git a/bdep/init.cli b/bdep/init.cli index 48d29ac..91ff2c6 100644 --- a/bdep/init.cli +++ b/bdep/init.cli @@ -15,7 +15,7 @@ namespace bdep <prj-spec> <prj-dir> <pkg-spec> <pkg-dir> <cfg-spec> <cfg-name> <cfg-dir> - <cfg-args> <cfg-var> <module> + <cfg-args> <option> <module> <cfg-var> <pkg-args> <pkg>", "\h|SYNOPSIS| @@ -30,7 +30,7 @@ namespace bdep <pkg-spec> = (\b{--directory}|\b{-d} <pkg-dir>)... | <prj-spec>\n <prj-spec> = \b{--directory}|\b{-d} <prj-dir>\n <pkg-args> = (<pkg> | <cfg-var>)...\n - <cfg-args> = (<module> | <cfg-var>)...} + <cfg-args> = (<option> | <module> | <cfg-var>)...} \h|DESCRIPTION| diff --git a/bdep/init.cxx b/bdep/init.cxx index 9b0ed37..6fda0a2 100644 --- a/bdep/init.cxx +++ b/bdep/init.cxx @@ -21,13 +21,13 @@ namespace bdep const dir_path& prj, database& db, const dir_path& cfg, + cli::scanner& args, bool ca, bool cc, optional<bool> cd) { const char* m (!ca ? "--config-create" : - !cc ? "--config-add" : - nullptr); + !cc ? "--config-add" : nullptr); if (m == nullptr) fail << "both --config-add and --config-create specified"; @@ -51,13 +51,8 @@ namespace bdep } return ca - ? cmd_config_add (prj, - db, - cfg, - move (name), - cd, - move (id)) - : nullptr; // @@ TODO: create + ? cmd_config_add ( prj, db, cfg, move (name), cd, move (id)) + : cmd_config_create (o, prj, db, cfg, args, move (name), cd, move (id)); } void @@ -129,7 +124,7 @@ namespace bdep } int - cmd_init (const cmd_init_options& o, cli::scanner&) + cmd_init (const cmd_init_options& o, cli::scanner& args) { tracer trace ("init"); @@ -200,6 +195,7 @@ namespace bdep prj, db, ca ? o.config_add () : o.config_create (), + args, ca, cc, cd)); diff --git a/bdep/init.hxx b/bdep/init.hxx index 1bb690b..7905306 100644 --- a/bdep/init.hxx +++ b/bdep/init.hxx @@ -20,6 +20,7 @@ namespace bdep const dir_path& prj, database&, const dir_path& cfg, + cli::scanner& cfg_args, bool config_add_specified, bool config_create_specified, optional<bool> config_default); diff --git a/bdep/new-types.hxx b/bdep/new-types.hxx index 0b2a4c6..b7161cd 100644 --- a/bdep/new-types.hxx +++ b/bdep/new-types.hxx @@ -35,9 +35,9 @@ namespace bdep BARE bare_opt; }; - // Default is bare with no options. + // Default is exe with no options. // - cmd_new_type_template (): type (bare) {bare_opt = BARE ();} + cmd_new_type_template (): type (exe) {bare_opt = BARE ();} friend ostream& operator<< (ostream& os, const cmd_new_type_template& t) diff --git a/bdep/new.cli b/bdep/new.cli index 6bbf07e..08eedc1 100644 --- a/bdep/new.cli +++ b/bdep/new.cli @@ -16,7 +16,7 @@ namespace bdep <type> <type-opt> <lang> <lang-opt> <cfg-name> <cfg-dir> - <cfg-args> <cfg-var> <module>", + <cfg-args> <option> <module> <cfg-var>", "\h|SYNOPSIS| @@ -28,7 +28,7 @@ namespace bdep \c{<spec> = [<type>] [<lang>]\n <type> = \b{--type}|\b{-t} (\b{exe}|\b{lib}|\b{bare})[\b{,}<type-opt>...]\n <lang> = \b{--lang}|\b{-l} (\b{c}|\b{c++})[\b{,}<lang-opt>...]\n - <cfg-args> = (<module> | <cfg-var>)...} + <cfg-args> = (<option> | <module> | <cfg-var>)...} \h|DESCRIPTION| @@ -104,8 +104,8 @@ namespace bdep { "<type>[,<opt>...]", "Specify project type and options. Valid values for <type> are \cb{exe} - (executable project) \cb{lib} (library project), and \cb{bare} (bare - project without any source code, default). Valid values for <opt> are + (executable project, default) \cb{lib} (library project), and \cb{bare} + (bare project without any source code). Valid values for <opt> are type-specific." } diff --git a/bdep/new.cxx b/bdep/new.cxx index 67ba23e..9ab63f4 100644 --- a/bdep/new.cxx +++ b/bdep/new.cxx @@ -358,6 +358,7 @@ namespace bdep prj, db, ca ? o.config_add () : o.config_create (), + args, ca, cc, cd)}; |