From e2b8f68fcae70fca5971167613916a1aa9480817 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 25 Mar 2018 10:07:31 +0200 Subject: Document new command, use --vcs|-s instead of --no-git --- bdep/new-parsers.cxx | 29 ++++++++++++++ bdep/new-parsers.hxx | 7 ++++ bdep/new-types.hxx | 30 +++++++++++++- bdep/new.cli | 108 +++++++++++++++++++++++++++++++++++++++++---------- bdep/new.cxx | 20 +++++++--- 5 files changed, 166 insertions(+), 28 deletions(-) diff --git a/bdep/new-parsers.cxx b/bdep/new-parsers.cxx index d5b8e6e..effa2a7 100644 --- a/bdep/new-parsers.cxx +++ b/bdep/new-parsers.cxx @@ -12,6 +12,7 @@ namespace bdep { using type = cmd_new_type; using lang = cmd_new_lang; + using vcs = cmd_new_vcs; // Parse comma-separated list of of options starting from the first comma // at pos. @@ -110,5 +111,33 @@ namespace bdep xs = true; } + + void parser:: + parse (vcs& r, bool& xs, scanner& s) + { + const char* o (s.next ()); + + if (!s.more ()) + throw missing_value (o); + + string v (s.next ()); + size_t i (v.find (',')); + string l (v, 0, i); + + if (l == "git") + { + r.vcs = vcs::git; + r.git_opt = parse_options (o, v, i); + } + else if (l == "none") + { + r.vcs = vcs::none; + r.none_opt = parse_options (o, v, i); + } + else + throw invalid_value (o, l); + + xs = true; + } } } diff --git a/bdep/new-parsers.hxx b/bdep/new-parsers.hxx index c496314..d50dc09 100644 --- a/bdep/new-parsers.hxx +++ b/bdep/new-parsers.hxx @@ -32,6 +32,13 @@ namespace bdep static void parse (cmd_new_lang&, bool&, scanner&); }; + + template <> + struct parser + { + static void + parse (cmd_new_vcs&, bool&, scanner&); + }; } } diff --git a/bdep/new-types.hxx b/bdep/new-types.hxx index b7161cd..616b87e 100644 --- a/bdep/new-types.hxx +++ b/bdep/new-types.hxx @@ -24,7 +24,7 @@ namespace bdep typename BARE = cmd_new_bare_options> struct cmd_new_type_template { - enum type_type {exe = 0, lib, bare} type; // Note: used as index. + enum type_type {exe, lib, bare} type; operator type_type () const {return type;} @@ -66,7 +66,7 @@ namespace bdep typename CXX = cmd_new_cxx_options> struct cmd_new_lang_template { - enum lang_type {c = 0, cxx} lang; // Note: used as index. + enum lang_type {c, cxx} lang; operator lang_type () const {return lang;} @@ -82,6 +82,32 @@ namespace bdep }; using cmd_new_lang = cmd_new_lang_template<>; + + // --vcs + // + class cmd_new_git_options; + class cmd_new_none_options; + + template + struct cmd_new_vcs_template + { + enum vcs_type {git, none} vcs; + + operator vcs_type () const {return vcs;} + + union + { + GIT git_opt; + NONE none_opt; + }; + + // Default is git with no options. + // + cmd_new_vcs_template (): vcs (git) {git_opt = GIT ();} + }; + + using cmd_new_vcs = cmd_new_vcs_template<>; } #endif // BDEP_NEW_TYPES_HXX diff --git a/bdep/new.cli b/bdep/new.cli index 08eedc1..377dbec 100644 --- a/bdep/new.cli +++ b/bdep/new.cli @@ -15,6 +15,7 @@ namespace bdep " +