mmc-utils: Add option to print version

This change adds support for printing the version as a command-line
argument. When any of 'ver', '-ver', '--ver', etc. are specified as the
first argument, mmc-utils will print its version string and exit.

This makes it easier for users and support personnel to quickly
determine the exact version of mmc-utils in use, which is especially
helpful for debugging and when users are running pre-built binaries.

Signed-off-by: Avri Altman <avri.altman@sandisk.com>
Link: https://lore.kernel.org/r/20250630072420.114967-2-avri.altman@sandisk.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
diff --git a/mmc.c b/mmc.c
index 315fa70..e941aa2 100644
--- a/mmc.c
+++ b/mmc.c
@@ -460,12 +460,18 @@
 	char		*prgname = get_prgname(argv[0]);
 	int		i=0, helprequested=0;
 
-	if( argc < 2 || !strcmp(argv[1], "help") ||
+	if(argc < 2 || !strcmp(argv[1], "help") ||
 		!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")){
 		help(prgname);
 		return 0;
 	}
 
+	if(!strcmp(argv[1], "ver") || !strcmp(argv[1], "-ver") || !strcmp(argv[1], "--ver") ||
+	   !strcmp(argv[1], "version") || !strcmp(argv[1], "-version") || !strcmp(argv[1], "--version")){
+		printf("%s\n", VERSION);
+		return 0;
+	}
+
 	for( cp = commands; cp->verb; cp++ )
 		if( !cp->ncmds)
 			cp->ncmds = split_command(cp->verb, &(cp->cmds));