aboutsummaryrefslogtreecommitdiff
path: root/bpkg
diff options
context:
space:
mode:
Diffstat (limited to 'bpkg')
-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
7 files changed, 130 insertions, 1 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
{