tools: add --version to ratbag-command
Behold, the glory of our version number!
#include <sys/stat.h>
#include <linux/input.h>
+#include "libratbag-version.h"
#include "shared.h"
enum options {
+ OPT_VERSION,
OPT_VERBOSE,
OPT_HELP,
};
@@ -187,6 +189,12 @@ usage(void)
program_invocation_short_name);
}
+static void
+version(void)
+{
+ printf("%s\n", LIBRATBAG_VERSION);
+}
+
static inline int
ratbag_cmd_device_from_arg(struct ratbag *ratbag,
int *argc, char **argv,
@@ -2039,6 +2047,7 @@ main(int argc, char **argv)
int option_index = 0;
static struct option opts[] = {
{ "verbose", optional_argument, 0, OPT_VERBOSE },
+ { "version", no_argument, 0, OPT_VERSION },
{ "help", no_argument, 0, OPT_HELP },
{ 0, 0, 0, 0 },
};
@@ -2051,6 +2060,9 @@ main(int argc, char **argv)
case OPT_HELP:
usage();
goto out;
+ case OPT_VERSION:
+ version();
+ goto out;
case OPT_VERBOSE:
if (optarg && streq(optarg, "raw"))
options.flags |= FLAG_VERBOSE_RAW;
