Skip to content

Commit

Permalink
CLI: -V now displays a short version string
Browse files Browse the repository at this point in the history
 * -v shows the full version output with build details
 * -V (capital V) shows only the short version string
  • Loading branch information
brndnmtthws committed May 1, 2024
1 parent 17bc14f commit d183ffa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/conky.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit d183ffa

Please sign in to comment.