From d0200a1576c5f0bf2cf29eb83432570441478daa Mon Sep 17 00:00:00 2001 From: Christoph Gysin Date: Fri, 28 Jul 2017 10:08:56 +0300 Subject: Add --version flag --- brightnessctl.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'brightnessctl.c') diff --git a/brightnessctl.c b/brightnessctl.c index 0e16b0e..f169608 100644 --- a/brightnessctl.c +++ b/brightnessctl.c @@ -86,6 +86,7 @@ static const struct option options[] = { {"pretend", no_argument, NULL, 'p'}, {"restore", no_argument, NULL, 'r'}, {"save", no_argument, NULL, 's'}, + {"version", no_argument, NULL, 'V'}, {NULL,} }; @@ -100,7 +101,7 @@ int main(int argc, char **argv) { if (strcmp(name.sysname, "Linux")) fail("This program only supports Linux.\n"); while (1) { - if ((c = getopt_long(argc, argv, "lqpmsrhc:d:", options, NULL)) < 0) + if ((c = getopt_long(argc, argv, "lqpmsrhVc:d:", options, NULL)) < 0) break; switch (c) { case 'l': @@ -130,6 +131,10 @@ int main(int argc, char **argv) { case 'd': p.device = strdup(optarg); break; + case 'V': + printf("%s\n", VERSION); + exit(0); + break; default: phelp++; } @@ -548,6 +553,7 @@ Options:\n\ -h, --help\t\t\tprint this help.\n\ -d, --device=DEVICE\t\tspecify device name.\n\ -c, --class=CLASS\t\tspecify device class.\n\ + -V, --version\t\t\tprint version and exit.\n\ \n\ Operations:\n\ i, info\t\t\tget device info.\n\ -- cgit v1.2.3