aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bpkg/bpkg.cli5
-rw-r--r--bpkg/bpkg.cxx2
-rw-r--r--bpkg/buildfile2
-rw-r--r--bpkg/cfg-info.cli62
-rw-r--r--bpkg/cfg-info.cxx41
-rw-r--r--bpkg/cfg-info.hxx18
-rw-r--r--bpkg/rep-info.cxx1
-rw-r--r--doc/buildfile1
-rwxr-xr-xdoc/cli.sh10
-rw-r--r--tests/cfg-create.testscript76
-rw-r--r--tests/common.testscript1
11 files changed, 206 insertions, 13 deletions
diff --git a/bpkg/bpkg.cli b/bpkg/bpkg.cli
index be9b639..caa33c0 100644
--- a/bpkg/bpkg.cli
+++ b/bpkg/bpkg.cli
@@ -172,6 +172,11 @@ namespace bpkg
"\l{bpkg-cfg-create(1)} \- create configuration"
}
+ bool cfg-info
+ {
+ "\l{bpkg-cfg-info(1)} \- print configuration information"
+ }
+
bool cfg-link
{
"\l{bpkg-cfg-link(1)} \- link configuration"
diff --git a/bpkg/bpkg.cxx b/bpkg/bpkg.cxx
index d1d26ca..4a4ac2d 100644
--- a/bpkg/bpkg.cxx
+++ b/bpkg/bpkg.cxx
@@ -21,6 +21,7 @@
//
#include <bpkg/help.hxx>
+#include <bpkg/cfg-info.hxx>
#include <bpkg/cfg-link.hxx>
#include <bpkg/cfg-create.hxx>
@@ -499,6 +500,7 @@ try
#define CFG_COMMAND(CMD, TMP) COMMAND_IMPL(cfg_, "cfg-", CMD, false, TMP)
CFG_COMMAND (create, false); // Temp dir initialized manually.
+ CFG_COMMAND (info, true);
CFG_COMMAND (link, true);
// pkg-* commands
diff --git a/bpkg/buildfile b/bpkg/buildfile
index 05bdf05..d32980b 100644
--- a/bpkg/buildfile
+++ b/bpkg/buildfile
@@ -16,6 +16,7 @@ import libs += libodb-sqlite%lib{odb-sqlite}
options_topics = \
bpkg-options \
cfg-create-options \
+cfg-info-options \
cfg-link-options \
common-options \
configuration-options \
@@ -151,6 +152,7 @@ if $cli.configured
# cfg-* command.
#
cli.cxx{cfg-create-options}: cli{cfg-create}
+ cli.cxx{cfg-info-options}: cli{cfg-info}
cli.cxx{cfg-link-options}: cli{cfg-link}
# rep-* command.
diff --git a/bpkg/cfg-info.cli b/bpkg/cfg-info.cli
new file mode 100644
index 0000000..5ce41c1
--- /dev/null
+++ b/bpkg/cfg-info.cli
@@ -0,0 +1,62 @@
+// file : bpkg/cfg-info.cli
+// license : MIT; see accompanying LICENSE file
+
+include <bpkg/configuration.cli>;
+
+"\section=1"
+"\name=bpkg-cfg-info"
+"\summary=print configuration information"
+
+namespace bpkg
+{
+ {
+ "<options> <dir>",
+
+ "\h|SYNOPSIS|
+
+ \c{\b{bpkg cfg-info} [<options>]}
+
+ \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}.
+
+ The output format is regular with each value printed on a separate line
+ and prefixed with the value name. For example:
+
+ \
+ path: /path/to/cfg/
+ uuid: 8d439f03-7342-4502-8b1c-74b173869478
+ type: target
+ name: foo
+ \
+ "
+ }
+
+ class cfg_info_options: configuration_options
+ {
+ "\h|CFG-INFO OPTIONS|"
+ };
+
+ "
+ \h|DEFAULT OPTIONS FILES|
+
+ See \l{bpkg-default-options-files(1)} for an overview of the default
+ options files. For the \cb{cfg-info} command the search start directory is
+ the configuration directory. The following options files are searched for
+ in each directory and, if found, loaded in the order listed:
+
+ \
+ bpkg.options
+ bpkg-cfg-info.options
+ \
+
+ The following \cb{cfg-info} command options cannot be specified in the
+ default options files:
+
+ \
+ --directory|-d
+ \
+ "
+}
diff --git a/bpkg/cfg-info.cxx b/bpkg/cfg-info.cxx
new file mode 100644
index 0000000..39008eb
--- /dev/null
+++ b/bpkg/cfg-info.cxx
@@ -0,0 +1,41 @@
+// file : bpkg/cfg-info.cxx -*- C++ -*-
+// license : MIT; see accompanying LICENSE file
+
+#include <bpkg/cfg-info.hxx>
+
+#include <iostream> // cout
+
+#include <bpkg/database.hxx>
+#include <bpkg/diagnostics.hxx>
+
+using namespace std;
+
+namespace bpkg
+{
+ int
+ cfg_info (const cfg_info_options& o, cli::scanner&)
+ {
+ tracer trace ("cfg_info");
+
+ dir_path c (o.directory ());
+ l4 ([&]{trace << "configuration: " << c;});
+
+ database db (c, trace, false /* pre_attach */);
+
+ 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;
+ }
+ catch (const io_error&)
+ {
+ fail << "unable to write to stdout";
+ }
+
+ return 0;
+ }
+}
diff --git a/bpkg/cfg-info.hxx b/bpkg/cfg-info.hxx
new file mode 100644
index 0000000..d4a8818
--- /dev/null
+++ b/bpkg/cfg-info.hxx
@@ -0,0 +1,18 @@
+// file : bpkg/cfg-info.hxx -*- C++ -*-
+// license : MIT; see accompanying LICENSE file
+
+#ifndef BPKG_CFG_INFO_HXX
+#define BPKG_CFG_INFO_HXX
+
+#include <bpkg/types.hxx>
+#include <bpkg/utility.hxx>
+
+#include <bpkg/cfg-info-options.hxx>
+
+namespace bpkg
+{
+ int
+ cfg_info (const cfg_info_options&, cli::scanner& args);
+}
+
+#endif // BPKG_CFG_INFO_HXX
diff --git a/bpkg/rep-info.cxx b/bpkg/rep-info.cxx
index 1a23528..c935114 100644
--- a/bpkg/rep-info.cxx
+++ b/bpkg/rep-info.cxx
@@ -328,7 +328,6 @@ namespace bpkg
}
else
serialize (cout, "stdout");
-
}
else
{
diff --git a/doc/buildfile b/doc/buildfile
index 2885b82..3af1782 100644
--- a/doc/buildfile
+++ b/doc/buildfile
@@ -3,6 +3,7 @@
cmds = \
bpkg-cfg-create \
+bpkg-cfg-info \
bpkg-cfg-link \
bpkg-help \
bpkg-pkg-build \
diff --git a/doc/cli.sh b/doc/cli.sh
index ac3dbc3..a2942bb 100755
--- a/doc/cli.sh
+++ b/doc/cli.sh
@@ -78,11 +78,11 @@ compile "pkg-build" $o --class-doc bpkg::pkg_build_pkg_options=exclude-base
# NOTE: remember to update a similar list in buildfile and bpkg.cli as well as
# the help topics sections in bpkg/buildfile and help.cxx.
#
-pages="cfg-create cfg-link help pkg-clean pkg-configure pkg-disfigure \
-pkg-drop pkg-fetch pkg-checkout pkg-install pkg-purge pkg-status pkg-test \
-pkg-uninstall pkg-unpack pkg-update pkg-verify rep-add rep-remove rep-list \
-rep-create rep-fetch rep-info repository-signing repository-types \
-argument-grouping default-options-files"
+pages="cfg-create cfg-info cfg-link help pkg-clean pkg-configure \
+pkg-disfigure pkg-drop pkg-fetch pkg-checkout pkg-install pkg-purge \
+pkg-status pkg-test pkg-uninstall pkg-unpack pkg-update pkg-verify rep-add \
+rep-remove rep-list rep-create rep-fetch rep-info repository-signing \
+repository-types argument-grouping default-options-files"
for p in $pages; do
compile $p $o
diff --git a/tests/cfg-create.testscript b/tests/cfg-create.testscript
index b96a98f..e518eea 100644
--- a/tests/cfg-create.testscript
+++ b/tests/cfg-create.testscript
@@ -7,9 +7,7 @@ config_cxx = config.cxx=$quote($recall($cxx.path) $cxx.config.mode, true)
cfg_create += 2>!
-# @@ To verify the creation result use cfg-list command rather than
-# pkg-status, when implemented.
-#
+cfg_info += -d cfg
pkg_status += -d cfg
: non-empty
@@ -34,6 +32,13 @@ EOE
info: type: target
EOE
+ $cfg_info >>/~"%EOO%";
+ %path: .+/cfg/%
+ %uuid: .{36}%
+ type: target
+ %name: %
+ EOO
+
$pkg_status libfoo >'libfoo unknown'
}
@@ -46,6 +51,13 @@ EOE
info: type: target
EOE
+ $cfg_info >>/~"%EOO%";
+ %path: .+/cfg/%
+ %uuid: .{36}%
+ type: target
+ %name: %
+ EOO
+
$pkg_status libfoo >'libfoo unknown';
cat cfg/build/config.build >>/~"%EOO%"
@@ -64,6 +76,13 @@ EOE
info: type: target
EOE
+ $cfg_info >>/~"%EOO%";
+ %path: .+/cfg/%
+ %uuid: .{36}%
+ type: target
+ %name: %
+ EOO
+
$pkg_status libfoo >'libfoo unknown';
cat cfg/build/config.build >>/~"%EOO%"
@@ -84,6 +103,13 @@ EOE
info: type: target
EOE
+ $cfg_info >>/~"%EOO%";
+ %path: .+/cfg/%
+ %uuid: .{36}%
+ type: target
+ %name: %
+ EOO
+
$pkg_status libfoo >'libfoo unknown'
}
@@ -98,6 +124,13 @@ EOE
info: type: target
EOE
+ $cfg_info >>/~"%EOO%";
+ %path: .+/cfg/%
+ %uuid: .{36}%
+ type: target
+ %name: %
+ EOO
+
$pkg_status libfoo >'libfoo unknown'
}
}
@@ -117,8 +150,13 @@ EOE
info: name: foo
EOE
- # @@ To verify the result use cfg-list, when implemented.
- #
+ $cfg_info >>/~"%EOO%";
+ %path: .+/cfg/%
+ %uuid: .{36}%
+ type: target
+ name: foo
+ EOO
+
$pkg_status libfoo >'libfoo unknown'
}
@@ -145,6 +183,13 @@ EOE
info: type: host
EOE
+ $cfg_info >>/~"%EOO%";
+ %path: .+/cfg/%
+ %uuid: .{36}%
+ type: host
+ %name: %
+ EOO
+
$pkg_status libfoo >'libfoo unknown'
}
@@ -165,12 +210,22 @@ EOE
: valid
:
{
- $* --config-uuid '18f48b4b-b5d9-4712-b98c-1930df1c4228' 2>>/~%EOE% &cfg/***;
+ uuid='18f48b4b-b5d9-4712-b98c-1930df1c4228';
+
+ $* --config-uuid $uuid --name foo 2>>/~"%EOE%" &cfg/***;
%created new configuration in .+/cfg/%
- info: uuid: 18f48b4b-b5d9-4712-b98c-1930df1c4228
+ info: uuid: $uuid
info: type: target
+ info: name: foo
EOE
+ $cfg_info >>/~"%EOO%";
+ %path: .+/cfg/%
+ uuid: $uuid
+ type: target
+ name: foo
+ EOO
+
$pkg_status libfoo >'libfoo unknown'
}
@@ -200,6 +255,13 @@ EOE
info: type: target
EOE
+ $cfg_info >>/~"%EOO%";
+ %path: .+/cfg/%
+ %uuid: .{36}%
+ type: target
+ %name: %
+ EOO
+
$pkg_status libfoo >'libfoo unknown'
}
diff --git a/tests/common.testscript b/tests/common.testscript
index 105bf3e..8af2cc7 100644
--- a/tests/common.testscript
+++ b/tests/common.testscript
@@ -33,6 +33,7 @@ test.options += --default-options $options_guard \
# as expected).
#
cfg_create = $* cfg-create
+cfg_info = $* cfg-info
cfg_link = $* cfg-link
pkg_build = $* pkg-build
pkg_checkout = $* pkg-checkout