From 0c2a4d6c3c832671a1f5647ab1b095adef2e985e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 15 May 2018 16:14:56 +0200 Subject: Implement -@foo as alternative to @foo, also add --config-name|-n An argument with leading '@' has special meaning in Windows PowerShell. --- bdep/bdep.cxx | 5 +++-- bdep/config.cxx | 22 +++++++++++++++------- bdep/project.cli | 16 +++++++++------- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/bdep/bdep.cxx b/bdep/bdep.cxx index c9d3234..c614cc0 100644 --- a/bdep/bdep.cxx +++ b/bdep/bdep.cxx @@ -88,9 +88,10 @@ init (const common_options& co, cli::group_scanner& scan, strings& args) continue; } - // @ + // @ & -@ // - if (*a == '@' && cfg_name (&o, a + 1)) + if ((*a == '@' && cfg_name (&o, a + 1)) || + (*a == '-' && a[1] == '@' && cfg_name (&o, a + 2))) { scan.next (); continue; diff --git a/bdep/config.cxx b/bdep/config.cxx index e75b817..2e50f5c 100644 --- a/bdep/config.cxx +++ b/bdep/config.cxx @@ -12,25 +12,33 @@ using namespace std; namespace bdep { - // Translate the configuration directory that is actually a name (@foo) to - // the real directory (prj-foo) and name (@foo). + // Translate the configuration directory that is actually a name (@foo or + // -@foo) to the real directory (prj-foo) and name (@foo). // static inline void translate_path_name (const dir_path& prj, dir_path& path, optional& name) { - if (name || !path.simple () || path.string ().front () != '@') + if (name || !path.simple ()) return; - string n (move (path).string ()); // Move out. - n.erase (0, 1); // Remove leading '@'. + size_t n; + { + const string& s (path.string ()); + if (s.size () > 1 && s[0] == '@') n = 1; + else if (s.size () > 2 && s[0] == '-' && s[1] == '@') n = 2; + else return; + } + + string s (move (path).string ()); // Move out. + s.erase (0, n); // Remove leading '@' or '-@'. path = prj; path += '-'; - path += n; + path += s; - name = move (n); + name = move (s); } shared_ptr diff --git a/bdep/project.cli b/bdep/project.cli index 0053c19..469e33d 100644 --- a/bdep/project.cli +++ b/bdep/project.cli @@ -54,18 +54,20 @@ namespace bdep // class configuration_name_options: common_options { + // Note that this is also used as storage for configuration names + // specified as @. + // + strings --config-name|-n + { + "", + "Specify the build configuration as a name." + }; + vector --config-id { "", "Specify the build configuration as an id." }; - - // Storage for configuration names specified as @. - // - // Note that we leave it undocumented so that it's not mentioned in - // documentation. - // - strings --config-name; }; // Common options for commands that operate on project/packages (prj-spec -- cgit v1.1