diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2022-07-19 20:20:47 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2022-07-20 13:48:26 +0300 |
commit | ddafa0f3475fe532a66879b807b0a8f47ecb201e (patch) | |
tree | 569a72699c810c9157c7ba1a6465d1af839017f1 /bdep/init.cxx | |
parent | 03cb180e90129ef3435dc8ad81deff1810a5c5bf (diff) |
Fail if no module specified for being created configuration
Diffstat (limited to 'bdep/init.cxx')
-rw-r--r-- | bdep/init.cxx | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/bdep/init.cxx b/bdep/init.cxx index 7533b4d..4599628 100644 --- a/bdep/init.cxx +++ b/bdep/init.cxx @@ -359,8 +359,12 @@ namespace bdep // Skip the first `--` separator, if any. // + bool sep (false); if (args.more () && args.peek () == string ("--")) + { + sep = true; args.next (); + } configurations cfgs; { @@ -374,8 +378,36 @@ namespace bdep // Read the configuration arguments until we reach the second `--` // separator or eos. // - for (string a; args.more () && (a = args.next ()) != "--"; ) - cfg_args.push_back (move (a)); + // Also make sure that there is at least one module unless the `--` + // separator is specified (see cmd_config_create() for details). + // + bool module (false); + while (args.more ()) + { + string a (args.next ()); + + if (a == "--") + { + sep = true; + break; + } + else + { + if (!sep) + { + if (a.find ('=') == string::npos) + module = true; + } + + cfg_args.push_back (move (a)); + } + } + + if (!sep && !module) + fail << "no module(s) specified for configuration to be created" << + info << "for example, for C/C++ configuration specify 'cc'" << + info << "use '--' to create configuration without modules" << + info << "for example: bdep init -C ... --"; } cfgs.push_back ( |