From aa891d19568b1108f57af72bd2052bda288aafb0 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Wed, 31 Oct 2012 10:58:17 +0200 Subject: [PATCH] bmap-flasher: implement --version option Change-Id: Iaea5577e387fb2a905231fef0dd5cd24c0a8e96c Signed-off-by: Artem Bityutskiy --- bmap-flasher | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/bmap-flasher b/bmap-flasher index d7bc33b..8bf2eb5 100755 --- a/bmap-flasher +++ b/bmap-flasher @@ -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) -- 2.7.4