bmap-flasher: implement --version option
authorArtem Bityutskiy <artem.bityutskiy@intel.com>
Wed, 31 Oct 2012 08:58:17 +0000 (10:58 +0200)
committerArtem Bityutskiy <artem.bityutskiy@intel.com>
Wed, 31 Oct 2012 09:36:56 +0000 (11:36 +0200)
Change-Id: Iaea5577e387fb2a905231fef0dd5cd24c0a8e96c
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
bmap-flasher

index d7bc33b..8bf2eb5 100755 (executable)
@@ -7,10 +7,10 @@
 """
 Write raw image file to the target block device using the block map file.
 The block map file contains the list of blocks which have to be written.
-
-TODO: 6 Implement --version option
 """
 
+VERSION = "0.1.0"
+
 import argparse
 import os
 import sys
@@ -40,7 +40,7 @@ def parse_arguments():
            "block device. There are also nice commentaries which make it "    \
            "easy to understand the bmap file contents."
 
-    parser = argparse.ArgumentParser(description = text)
+    parser = argparse.ArgumentParser(description = text, prog = 'bmap-flasher')
 
     # The first command-line argument - block device node
     text = "The block device node to flash the image to."
@@ -69,6 +69,10 @@ def parse_arguments():
     text = "Be quiet"
     parser.add_argument("-q", "--quiet", action="store_true", help = text)
 
+    # The --version option
+    parser.add_argument("--version", action="version", \
+                        version="%(prog)s " + "%s" % VERSION)
+
     return parser.parse_args()
 
 def human_size(size):
@@ -83,6 +87,7 @@ def human_size(size):
 
 def human_time(seconds):
     """ Transform time in seconds to the HH:MM:SS format. """
+
     (minutes, seconds) = divmod(seconds, 60)
     (hours, minutes) = divmod(minutes, 60)