Skip to content

Commit c6c2b1d

Browse files
committed
Add --version option
1 parent 36b96ec commit c6c2b1d

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

meson.build

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ project(
44
meson_version: '>=0.60.0',
55
default_options: ['c_std=c11'],
66
license: 'GPL-3.0',
7-
version: '0.2.3',
7+
version: '0.3.0',
88
)
99

1010
use_opencv = get_option('opencv').enabled()
1111

1212
add_project_arguments('-D_GNU_SOURCE=200809L', language: 'c')
13+
add_project_arguments('-DVERSION="@0@"'.format(meson.project_version()), language: 'c')
1314
cc = meson.get_compiler('c')
1415

1516
if use_opencv

src/main.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,7 @@ static void print_usage() {
661661

662662
puts(" -h, --help show this help");
663663
puts(" --help-config show help on configuration");
664+
puts(" -v, --version show version");
664665
puts(" -c, --config=FILE use given configuration file");
665666
puts(" -r, --restrict=AREA restrict to given area (wxh+x+y)");
666667
puts(" -o, --option set configuration option");
@@ -670,6 +671,14 @@ static void print_usage() {
670671
);
671672
}
672673

674+
static void print_version() {
675+
printf("wl-kbptr %s", VERSION);
676+
#if OPENCV_ENABLED
677+
printf(" (opencv)");
678+
#endif
679+
puts("");
680+
}
681+
673682
int main(int argc, char **argv) {
674683
struct state state = {
675684
.wl_display = NULL,
@@ -701,6 +710,7 @@ int main(int argc, char **argv) {
701710
static struct option long_options[] = {
702711
{"help", no_argument, 0, 'h'},
703712
{"help-config", no_argument, 0, 'H'},
713+
{"version", no_argument, 0, 'v'},
704714
{"restrict", required_argument, 0, 'r'},
705715
{"config", required_argument, 0, 'c'},
706716
{"output", required_argument, 0, 'O'},
@@ -720,6 +730,10 @@ int main(int argc, char **argv) {
720730
print_usage();
721731
return 0;
722732

733+
case 'v':
734+
print_version();
735+
return 0;
736+
723737
case 'r':
724738
if (sscanf(
725739
optarg, "%dx%d+%d+%d", &state.initial_area.w,

0 commit comments

Comments
 (0)