aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Christoph Gysin <christoph.gysin@gmail.com>2017-07-28 10:08:56 +0300
committerGravatar Hummer12007 <hilobakho@gmail.com>2017-07-28 14:07:15 +0300
commitd0200a1576c5f0bf2cf29eb83432570441478daa (patch)
treef8c557b970200b669fe7e6cf9bc518f3a93dc70d
parenta096c25149dd1bdf1c8a1c761a82890495498662 (diff)
Add --version flag
-rw-r--r--README.md1
-rw-r--r--brightnessctl.c8
2 files changed, 8 insertions, 1 deletions
diff --git a/README.md b/README.md
index 68909ac..5aaa3ce 100644
--- a/README.md
+++ b/README.md
@@ -38,6 +38,7 @@ Options:
-h, --help print this help.
-d, --device=DEVICE specify device name.
-c, --class=CLASS specify device class.
+ -V, --version print version and exit.
Operations:
i, info get device info.
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\