Skip to content

Commit 32c7172

Browse files
author
4G3NT
committed
Prevent -v from printing version if no additional arguments are provided print usage instead.
1 parent 0900ecb commit 32c7172

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

man/tldr.1

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ used commandline tools.
1414
.BR \-v ", " \-\-verbose
1515
verbose output (when used with \fB\-c\fR or \fB\-u\fR)
1616
.TP
17-
.BR \-v ", " \-\-version
18-
output version information and exit
19-
.TP
2017
.BR \-h ", " \-\-help
2118
display help and exit
2219
.TP
@@ -44,6 +41,8 @@ show command page for OSX
4441
.B \-\-sunos
4542
show command page for SunOS
4643
.TP
44+
.B \-\-version
45+
output version information and exit
4746
.SH EXIT STATUS
4847
0 on success, any other positive value otherwise
4948
.SH SEE ALSO

src/tldr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ main(int argc, char **argv)
138138
return EXIT_SUCCESS;
139139
}
140140
if (verbose_flag && optind >= argc) {
141-
print_version(argv[0]);
141+
print_usage(argv[0]);
142142
return EXIT_SUCCESS;
143143
}
144144
if (list_flag) {
@@ -210,7 +210,6 @@ print_usage(char const *arg)
210210
fprintf(stdout, out, arg);
211211
fprintf(stdout, "available commands:\n");
212212
fprintf(stdout, " %-23s %s\n", "-v, --verbose", "verbose output (when used with -c or -u)");
213-
fprintf(stdout, " %-23s %s\n", "-v, --version", "print version and exit");
214213
fprintf(stdout, " %-23s %s\n", "-h, --help", "print this help and exit");
215214
fprintf(stdout, " %-23s %s\n", "-u, --update", "update local database");
216215
fprintf(stdout, " %-23s %s\n", "-c, --clear-cache", "clear local database");
@@ -222,6 +221,7 @@ print_usage(char const *arg)
222221
fprintf(stdout, " %-23s %s\n", "--linux", "show command page for Linux");
223222
fprintf(stdout, " %-23s %s\n", "--osx", "show command page for OSX");
224223
fprintf(stdout, " %-23s %s\n", "--sunos", "show command page for SunOS");
224+
fprintf(stdout, " %-23s %s\n", "--version", "print version and exit");
225225
/* *INDENT-ON* */
226226
}
227227

0 commit comments

Comments
 (0)