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/bdep.cxx | 19 +++++++++---------- bdep/buildfile | 2 +- bdep/config.cli | 17 ++++++++++++----- bdep/config.cxx | 46 ++++++++++++++++++++++++++++++++++++++-------- bdep/config.hxx | 15 +++++++++++++-- bdep/init.cli | 4 ++-- bdep/init.cxx | 16 ++++++---------- bdep/init.hxx | 1 + bdep/new-types.hxx | 4 ++-- bdep/new.cli | 8 ++++---- 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; - // @ // - 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 " \ --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 " - ", +