Add version command line flag

master
Kenny Levinsen 2021-02-01 13:24:17 +01:00
parent 111181106e
commit 53d19e4c76
2 changed files with 7 additions and 1 deletions

6
main.c
View File

@ -713,6 +713,7 @@ static int parse_time_of_day(const char *s, time_t *time) {
static const char usage[] = "usage: %s [options]\n"
" -h show this help message\n"
" -v show the version number\n"
" -t <temp> set low temperature (default: 4000)\n"
" -T <temp> set high temperature (default: 6500)\n"
" -l <lat> set latitude (e.g. 39.9)\n"
@ -737,7 +738,7 @@ int main(int argc, char *argv[]) {
};
int opt;
while ((opt = getopt(argc, argv, "ht:T:l:L:S:s:d:g:")) != -1) {
while ((opt = getopt(argc, argv, "hvt:T:l:L:S:s:d:g:")) != -1) {
switch (opt) {
case 't':
config.low_temp = strtol(optarg, NULL, 10);
@ -771,6 +772,9 @@ int main(int argc, char *argv[]) {
case 'g':
config.gamma = strtod(optarg, NULL);
break;
case 'v':
printf("wlsunset version %s\n", WLSUNSET_VERSION);
return EXIT_SUCCESS;
case 'h':
default:
fprintf(stderr, usage, argv[0]);

View File

@ -1,6 +1,7 @@
project(
'wlsunset',
'c',
version: '0.1.0',
license: 'MIT',
meson_version: '>=0.53.0',
default_options: [
@ -27,6 +28,7 @@ add_project_arguments(
'-Wl,--exclude-libs=ALL',
'-D_USE_MATH_DEFINES',
'-D_XOPEN_SOURCE=700',
'-DWLSUNSET_VERSION="@0@"'.format(meson.project_version()),
],
language: 'c',
)