Skip to content

Commit

Permalink
Prevent -v from printing version if no additional arguments are provi…
Browse files Browse the repository at this point in the history
…ded print usage instead.
  • Loading branch information
4G3NT committed Jul 24, 2023
1 parent 0900ecb commit 32c7172
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions man/tldr.1
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ used commandline tools.
.BR \-v ", " \-\-verbose
verbose output (when used with \fB\-c\fR or \fB\-u\fR)
.TP
.BR \-v ", " \-\-version
output version information and exit
.TP
.BR \-h ", " \-\-help
display help and exit
.TP
Expand Down Expand Up @@ -44,6 +41,8 @@ show command page for OSX
.B \-\-sunos
show command page for SunOS
.TP
.B \-\-version
output version information and exit
.SH EXIT STATUS
0 on success, any other positive value otherwise
.SH SEE ALSO
Expand Down
4 changes: 2 additions & 2 deletions src/tldr.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ main(int argc, char **argv)
return EXIT_SUCCESS;
}
if (verbose_flag && optind >= argc) {
print_version(argv[0]);
print_usage(argv[0]);
return EXIT_SUCCESS;
}
if (list_flag) {
Expand Down Expand Up @@ -210,7 +210,6 @@ print_usage(char const *arg)
fprintf(stdout, out, arg);
fprintf(stdout, "available commands:\n");
fprintf(stdout, " %-23s %s\n", "-v, --verbose", "verbose output (when used with -c or -u)");
fprintf(stdout, " %-23s %s\n", "-v, --version", "print version and exit");
fprintf(stdout, " %-23s %s\n", "-h, --help", "print this help and exit");
fprintf(stdout, " %-23s %s\n", "-u, --update", "update local database");
fprintf(stdout, " %-23s %s\n", "-c, --clear-cache", "clear local database");
Expand All @@ -222,6 +221,7 @@ print_usage(char const *arg)
fprintf(stdout, " %-23s %s\n", "--linux", "show command page for Linux");
fprintf(stdout, " %-23s %s\n", "--osx", "show command page for OSX");
fprintf(stdout, " %-23s %s\n", "--sunos", "show command page for SunOS");
fprintf(stdout, " %-23s %s\n", "--version", "print version and exit");
/* *INDENT-ON* */
}

0 comments on commit 32c7172

Please sign in to comment.