From 6cb3eff4780aeeaf0757a0410f62f2cc5ac9f3b0 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 6 Aug 2021 19:25:23 +0300 Subject: Add --link option to cfg-info --- bpkg/cfg-info.cxx | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'bpkg/cfg-info.cxx') diff --git a/bpkg/cfg-info.cxx b/bpkg/cfg-info.cxx index 39008eb..da49d62 100644 --- a/bpkg/cfg-info.cxx +++ b/bpkg/cfg-info.cxx @@ -20,16 +20,35 @@ namespace bpkg dir_path c (o.directory ()); l4 ([&]{trace << "configuration: " << c;}); - database db (c, trace, false /* pre_attach */); + database db (c, trace, o.link ()); try { cout.exceptions (ostream::badbit | ostream::failbit); - cout << "path: " << db.config << endl - << "uuid: " << db.uuid << endl - << "type: " << db.type << endl - << "name: " << (db.name ? *db.name : "") << endl; + auto print = [] (const database& db) + { + cout << "path: " << db.config << endl + << "uuid: " << db.uuid << endl + << "type: " << db.type << endl + << "name: " << (db.name ? *db.name : "") << endl; + }; + + print (db); + + // Note that there will be no explicit links loaded, unless the --link + // option is specified. + // + for (const linked_config& lc: db.explicit_links ()) + { + // Skip the self-link. + // + if (lc.id != 0) + { + cout << endl; + print (lc.db); + } + } } catch (const io_error&) { -- cgit v1.1