aboutsummaryrefslogtreecommitdiff
path: root/bpkg
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-07-12 16:59:27 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-07-12 19:55:03 +0300
commitfa9017f87197565b970d22d2d51241fdfa55c916 (patch)
tree14e0e4e14465a1b81614400077112a35de92ef65 /bpkg
parent6fc547881a3cce4c9a96d371a2b168d68159eb5d (diff)
Add --manifest option to pkg-verify
Diffstat (limited to 'bpkg')
-rw-r--r--bpkg/pkg-verify.cli6
-rw-r--r--bpkg/pkg-verify.cxx21
-rw-r--r--bpkg/rep-info.cli2
3 files changed, 27 insertions, 2 deletions
diff --git a/bpkg/pkg-verify.cli b/bpkg/pkg-verify.cli
index f4f3214..5432743 100644
--- a/bpkg/pkg-verify.cli
+++ b/bpkg/pkg-verify.cli
@@ -42,5 +42,11 @@ namespace bpkg
declare such a package valid since it cannot be sure the unknown entries
are valid."
}
+
+ bool --manifest
+ {
+ "Instead of printing the successful verification result in the
+ human-readable form, dump the package manifest to \cb{stdout}."
+ }
};
}
diff --git a/bpkg/pkg-verify.cxx b/bpkg/pkg-verify.cxx
index 2711394..69014ac 100644
--- a/bpkg/pkg-verify.cxx
+++ b/bpkg/pkg-verify.cxx
@@ -4,8 +4,11 @@
#include <bpkg/pkg-verify.hxx>
+#include <iostream> // cout
+
#include <libbutl/process.mxx>
#include <libbutl/manifest-parser.mxx>
+#include <libbutl/manifest-serializer.mxx>
#include <bpkg/archive.hxx>
#include <bpkg/diagnostics.hxx>
@@ -189,7 +192,23 @@ namespace bpkg
package_manifest m (
pkg_verify (o, a, o.ignore_unknown (), !o.silent ()));
- if (verb && !o.silent () && !o.no_result ())
+ if (o.manifest ())
+ {
+ try
+ {
+ manifest_serializer s (cout, "STDOUT");
+ m.serialize (s);
+ }
+ catch (const manifest_serialization& e)
+ {
+ fail << "unable to serialize manifest: " << e.description;
+ }
+ catch (const io_error&)
+ {
+ fail << "unable to write to STDOUT";
+ }
+ }
+ else if (verb && !o.silent () && !o.no_result ())
text << "valid package " << m.name << " " << m.version;
return 0;
diff --git a/bpkg/rep-info.cli b/bpkg/rep-info.cli
index 17bf499..35afd55 100644
--- a/bpkg/rep-info.cli
+++ b/bpkg/rep-info.cli
@@ -85,7 +85,7 @@ namespace bpkg
"Print the list of available packages."
}
- bool --manifest|-m
+ bool --manifest
{
"Instead of printing the information in the human-readable form, dump it
as manifest(s). Normally you would use this option in combination with