From 8cc86445437e7afc583dee18b36c0e8ba4b6fe12 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 12 Dec 2022 18:35:08 +0300 Subject: Add support for omitting sub-projects from b_info() result --- libbutl/b.cxx | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'libbutl/b.cxx') diff --git a/libbutl/b.cxx b/libbutl/b.cxx index ee5c8a5..3d78803 100644 --- a/libbutl/b.cxx +++ b/libbutl/b.cxx @@ -35,7 +35,7 @@ namespace butl void b_info (std::vector& r, const vector& projects, - bool ext_mods, + b_info_flags fl, uint16_t verb, const function& cmd_callback, const path& program, @@ -81,13 +81,20 @@ namespace butl else vops.push_back ("-q"); - vector ps; - ps.reserve (projects.size ()); + string spec ("info("); - // Note that quoting is essential here. - // - for (const dir_path& p: projects) - ps.push_back ('\'' + p.representation () + '\''); + for (size_t i (0); i != projects.size(); ++i) + { + if (i != 0) + spec += ' '; + + spec += '\'' + projects[i].representation () + '\''; + } + + if ((fl & b_info_flags::subprojects) == b_info_flags::none) + spec += ",no_subprojects"; + + spec += ')'; pr = process_start_callback ( cmd_callback ? cmd_callback : [] (const char* const*, size_t) {}, @@ -96,10 +103,12 @@ namespace butl 2 /* stderr */, pp, vops, - ext_mods ? nullptr : "--no-external-modules", + ((fl & b_info_flags::ext_mods) == b_info_flags::none + ? "--no-external-modules" + : nullptr), "-s", ops, - "info:", ps); + spec); pipe.out.close (); ifdstream is (move (pipe.in), fdstream_mode::skip, ifdstream::badbit); -- cgit v1.1