diff mbox series

Add parameter to ask SWUpdate version

Message ID 1519202756-23590-1-git-send-email-sbabic@denx.de
State Accepted
Headers show
Series Add parameter to ask SWUpdate version | expand

Commit Message

Stefano Babic Feb. 21, 2018, 8:45 a.m. UTC
Return immediately SWUpdate's version. This can be used in scripts
when command line parameters depend on SWupdate's version.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 core/swupdate.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/core/swupdate.c b/core/swupdate.c
index 430bb96..0538b74 100644
--- a/core/swupdate.c
+++ b/core/swupdate.c
@@ -70,6 +70,7 @@  struct flash_description *get_flash_info(void) {
 
 static struct option long_options[] = {
 	{"verbose", no_argument, NULL, 'v'},
+	{"version", no_argument, NULL, '0'},
 	{"image", required_argument, NULL, 'i'},
 	{"file", required_argument, NULL, 'f'},
 	{"loglevel", required_argument, NULL, 'l'},
@@ -572,10 +573,6 @@  int main(int argc, char **argv)
 
 	memset(fname, 0, sizeof(fname));
 
-	printf("%s\n", BANNER);
-	printf("Licensed under GPLv2. See source distribution for detailed "
-		"copyright notices.\n\n");
-
 	/* Initialize internal database */
 	swupdate_init(&swcfg);
 
@@ -618,9 +615,16 @@  int main(int argc, char **argv)
 				exit(1);
 			}
 			break;
+		case '0':
+			printf("%s", BANNER);
+			exit(0);
 		}
 	}
 
+	printf("%s\n", BANNER);
+	printf("Licensed under GPLv2. See source distribution for detailed "
+		"copyright notices.\n\n");
+
 	/*
 	 * Command line should be parsed a second time
 	 * This let line parameters overload