diff options
-rw-r--r-- | bpkg/cfg-info.cli | 24 | ||||
-rw-r--r-- | bpkg/cfg-info.cxx | 29 | ||||
-rw-r--r-- | tests/cfg-create.testscript | 12 | ||||
-rw-r--r-- | tests/cfg-link.testscript | 46 |
4 files changed, 98 insertions, 13 deletions
diff --git a/bpkg/cfg-info.cli b/bpkg/cfg-info.cli index 5ce41c1..8002abd 100644 --- a/bpkg/cfg-info.cli +++ b/bpkg/cfg-info.cli @@ -19,17 +19,30 @@ namespace bpkg \h|DESCRIPTION| The \cb{cfg-info} command prints the current configuration's absolute - path, id, type, and name. Note that the information is written to - \cb{stdout}, not \cb{stderr}. + path, id, type, and name. If the \cb{--link} option is specified then + this information is also printed for each linked configuration, if any. + Note that the information is written to \cb{stdout}, not \cb{stderr}. The output format is regular with each value printed on a separate line - and prefixed with the value name. For example: + and prefixed with the value name. If the \cb{--link} option is specified + then information blocks corresponding to configurations are separated + with blank lines. For example: \ path: /path/to/cfg/ uuid: 8d439f03-7342-4502-8b1c-74b173869478 type: target name: foo + + path: /path/to/host-cfg/ + uuid: 7ee4dab3-07d9-4163-81c0-3779166a7213 + type: host + name: tools + + path: /path/to/build2-cfg/ + uuid: d453aa2a-92c4-4066-87e4-c8672eed06e1 + type: build2 + name: modules \ " } @@ -37,6 +50,11 @@ namespace bpkg class cfg_info_options: configuration_options { "\h|CFG-INFO OPTIONS|" + + bool --link + { + "Print linked configurations." + } }; " 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&) { diff --git a/tests/cfg-create.testscript b/tests/cfg-create.testscript index 25225ba..e69629d 100644 --- a/tests/cfg-create.testscript +++ b/tests/cfg-create.testscript @@ -255,11 +255,21 @@ EOE type: target EOE - $cfg_info >>/~"%EOO%"; + $cfg_info --link >>/~"%EOO%"; %path: .+/cfg/% %uuid: .{36}% type: target %name: % + + %path: .+/host/% + %uuid: .{36}% + type: host + %name: % + + %path: .+/build2/% + %uuid: .{36}% + type: build2 + %name: % EOO $pkg_status libfoo >'libfoo unknown' diff --git a/tests/cfg-link.testscript b/tests/cfg-link.testscript index 5d903f2..26496eb 100644 --- a/tests/cfg-link.testscript +++ b/tests/cfg-link.testscript @@ -4,10 +4,7 @@ .include common.testscript cfg_create += 2>! - -# @@ To verify the linking result use cfg-list command rather than pkg-status, -# when implemented. -# +cfg_info += --link test.arguments += -d cfg @@ -44,6 +41,18 @@ acfg_uuid = '28f48b4b-b5d9-4712-b98c-1930df1c4228' id: 1 EOE + $cfg_info -d cfg >>/~"%EOO%"; + path: $~/cfg/ + %uuid: .{36}% + type: target + name: main + + path: $~/acfg/ + uuid: $acfg_uuid + type: target + name: shared + EOO + $pkg_status -d cfg libfoo >'libfoo unknown'; $pkg_status -d acfg libfoo >'libfoo unknown'; @@ -107,6 +116,23 @@ acfg_uuid = '28f48b4b-b5d9-4712-b98c-1930df1c4228' rm -r acfg; $cfg_create -d acfg --name 'shared' --uuid "$acfg_uuid" &acfg/***; + $cfg_info -d cfg >>/~"%EOO%"; + path: $~/cfg/ + %uuid: .{36}% + type: target + name: test + + path: $~/acfg/ + uuid: $acfg_uuid + type: target + name: shared + + path: $~/acfg2/ + %uuid: .{36}% + type: target + name: shared + EOO + $pkg_status -d cfg libfoo >'libfoo unknown'; $pkg_status -d acfg2 libfoo >'libfoo unknown'; @@ -134,6 +160,18 @@ acfg_uuid = '28f48b4b-b5d9-4712-b98c-1930df1c4228' id: 1 EOE + $cfg_info -d acfg2 >>/~"%EOO%"; + path: $~/acfg2/ + %uuid: .{36}% + type: target + name: shared + + path: $~/cfg/ + %uuid: .{36}% + type: target + name: test + EOO + $pkg_status -d cfg libfoo >'libfoo unknown'; $pkg_status -d acfg2 libfoo >'libfoo unknown'; |