From d183ffabd96699b95deb50c0de1cb7eba841bc28 Mon Sep 17 00:00:00 2001 From: Brenden Matthews Date: Wed, 1 May 2024 14:26:59 -0400 Subject: [PATCH] CLI: -V now displays a short version string * -v shows the full version output with build details * -V (capital V) shows only the short version string --- src/conky.cc | 6 +++--- src/main.cc | 9 +++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/conky.cc b/src/conky.cc index 327f3f596..a49ec4c85 100644 --- a/src/conky.cc +++ b/src/conky.cc @@ -2101,9 +2101,9 @@ const char *getopt_string = ; const struct option longopts[] = { - {"help", 0, nullptr, 'h'}, {"version", 0, nullptr, 'V'}, - {"quiet", 0, nullptr, 'q'}, {"debug", 0, nullptr, 'D'}, - {"config", 1, nullptr, 'c'}, + {"help", 0, nullptr, 'h'}, {"version", 0, nullptr, 'v'}, + {"short-version", 0, nullptr, 'V'}, {"quiet", 0, nullptr, 'q'}, + {"debug", 0, nullptr, 'D'}, {"config", 1, nullptr, 'c'}, #ifdef BUILD_BUILTIN_CONFIG {"print-config", 0, nullptr, 'C'}, #endif diff --git a/src/main.cc b/src/main.cc index fd73166a4..8e937c61e 100644 --- a/src/main.cc +++ b/src/main.cc @@ -56,6 +56,8 @@ #endif /* BUILD_OLD_CONFIG */ #endif /* BUILD_BUILTIN_CONFIG */ +static void print_short_version() { std::cout << VERSION << std::endl; } + static void print_version() { std::cout << _(PACKAGE_NAME " " VERSION " compiled for " BUILD_ARCH "\n" @@ -232,7 +234,8 @@ static void print_help(const char *prog_name) { "window. Command line options will override configurations defined in " "config\n" "file.\n" - " -v, --version version\n" + " -v, --version version with build details\n" + " -V, --short-version short version\n" " -q, --quiet quiet mode\n" " -D, --debug increase debugging output, ie. -DD for " "more debugging\n" @@ -320,9 +323,11 @@ int main(int argc, char **argv) { global_debug_level++; break; case 'v': - case 'V': print_version(); return EXIT_SUCCESS; + case 'V': + print_short_version(); + return EXIT_SUCCESS; case 'c': current_config = optarg; break;