From d581251ca28d052e960ff6d0d6fd234d1ff2baf0 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Thu, 16 Sep 2021 17:19:16 -0700 Subject: vmon: add --version flag --- src/vmon.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/vmon.c') diff --git a/src/vmon.c b/src/vmon.c index 30ed630..c8e21f9 100644 --- a/src/vmon.c +++ b/src/vmon.c @@ -175,7 +175,6 @@ static int set_fullscreen(vmon_t *vmon) } -/* print commandline help */ static void print_help(void) { puts( @@ -194,12 +193,18 @@ static void print_help(void) " -z --hertz Sample rate in hertz\n" " -o --output-dir Directory to store saved output to (\".\" if unspecified)\n" " -s --snapshot Save a PNG snapshot upon receiving SIGCHLD\n" + " -v --version Print version\n" "-----------------------------------------------------------------------------" ); } -/* print copyright */ +static void print_version(void) +{ + puts("vmon " VERSION); +} + + static void print_copyright(void) { puts( @@ -290,6 +295,9 @@ static int vmon_handle_argv(vmon_t *vmon, int argc, char * const argv[]) } else if (is_flag(*argv, "-h", "--help")) { print_help(); exit(EXIT_SUCCESS); + } else if (is_flag(*argv, "-v", "--version")) { + print_version(); + exit(EXIT_SUCCESS); } else if ((*argv)[0] == '-') { VWM_ERROR("Unrecognized argument: \"%s\", try --help\n", argv[0]); exit(EXIT_FAILURE); -- cgit v1.2.3