imgtool: Add 'dumpinfo' command

Add new 'dumpinfo' command that can parse a signed image and
print all the available information from the header, TLV area and
trailer in the form of a basic "image map".

The --outfile option can be used to write the image information
to an output file in serialised YAML format.

Change-Id: I99e61078946b02eefd4ac2e682583476d53e8d4f
Signed-off-by: David Vincze <david.vincze@arm.com>
diff --git a/scripts/imgtool/main.py b/scripts/imgtool/main.py
index 8b515d5..2df06e1 100755
--- a/scripts/imgtool/main.py
+++ b/scripts/imgtool/main.py
@@ -25,6 +25,7 @@
 import base64
 from imgtool import image, imgtool_version
 from imgtool.version import decode_version
+from imgtool.dumpinfo import dump_imginfo
 from .keys import (
     RSAUsageError, ECDSAUsageError, Ed25519UsageError, X25519UsageError)
 
@@ -190,6 +191,18 @@
     sys.exit(1)
 
 
+@click.argument('imgfile')
+@click.option('-o', '--outfile', metavar='filename', required=False,
+              help='Save image information to outfile in YAML format')
+@click.option('-s', '--silent', default=False, is_flag=True,
+              help='Do not print image information to output')
+@click.command(help='Print header, TLV area and trailer information '
+                    'of a signed image')
+def dumpinfo(imgfile, outfile, silent):
+    dump_imginfo(imgfile, outfile, silent)
+    print("dumpinfo has run successfully")
+
+
 def validate_version(ctx, param, value):
     try:
         decode_version(value)
@@ -462,6 +475,7 @@
 imgtool.add_command(verify)
 imgtool.add_command(sign)
 imgtool.add_command(version)
+imgtool.add_command(dumpinfo)
 
 
 if __name__ == '__main__':