diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2021-10-16 09:08:46 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2021-10-16 09:08:46 +0200 |
commit | f034a1bb4a7458e53e438b696713129c099bd185 (patch) | |
tree | 43746e7519c6965fdbbdfd104b4e0a572e091a89 /libbuild2/operation.cxx | |
parent | 0b1fe4da132d45db3309fac6b9b18726d98ea58e (diff) |
Improve info meta-operation not to print trailing spaces
Diffstat (limited to 'libbuild2/operation.cxx')
-rw-r--r-- | libbuild2/operation.cxx | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/libbuild2/operation.cxx b/libbuild2/operation.cxx index ae0f2d8..f1fc83c 100644 --- a/libbuild2/operation.cxx +++ b/libbuild2/operation.cxx @@ -569,20 +569,34 @@ namespace build2 cout << ' ' << ms.name; }; + // Print a potentially empty/null instance. + // + auto print_empty = [] (const auto& x) + { + if (!x.empty ()) + cout << ' ' << x; + }; + + auto print_null = [] (const auto* p) + { + if (p != nullptr && !p->empty ()) + cout << ' ' << *p; + }; + // This could be a simple project that doesn't set project name. // cout - << "project: " << project (rs) << endl - << "version: " << cast_empty<string> (rs[ctx.var_version]) << endl - << "summary: " << cast_empty<string> (rs[ctx.var_project_summary]) << endl - << "url: " << cast_empty<string> (rs[ctx.var_project_url]) << endl + << "project:" ; print_empty (project (rs)); cout << endl + << "version:" ; print_empty (cast_empty<string> (rs[ctx.var_version])); cout << endl + << "summary:" ; print_empty (cast_empty<string> (rs[ctx.var_project_summary])); cout << endl + << "url:" ; print_empty (cast_empty<string> (rs[ctx.var_project_url])); cout << endl << "src_root: " << cast<dir_path> (rs[ctx.var_src_root]) << endl << "out_root: " << cast<dir_path> (rs[ctx.var_out_root]) << endl - << "amalgamation: " << (*rs.root_extra->amalgamation != nullptr ? **rs.root_extra->amalgamation : empty_dir_path) << endl - << "subprojects: " << (*rs.root_extra->subprojects != nullptr ? **rs.root_extra->subprojects : subprojects ()) << endl - << "operations:"; print_ops (rs.root_extra->operations, ctx.operation_table); cout << endl + << "amalgamation:" ; print_null (*rs.root_extra->amalgamation); cout << endl + << "subprojects:" ; print_null (*rs.root_extra->subprojects); cout << endl + << "operations:" ; print_ops (rs.root_extra->operations, ctx.operation_table); cout << endl << "meta-operations:"; print_ops (rs.root_extra->meta_operations, ctx.meta_operation_table); cout << endl - << "modules:"; print_mods (); cout << endl; + << "modules:" ; print_mods (); cout << endl; } } |