Skip to content

Commit

Permalink
Make all user commands handle --help and --version
Browse files Browse the repository at this point in the history
  • Loading branch information
CendioOssman committed Dec 3, 2024
1 parent c1f77c6 commit fbe098a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
9 changes: 9 additions & 0 deletions unix/vncconfig/vncconfig.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,15 @@ int main(int argc, char** argv)
continue;
}

if (strcmp(argv[i], "-help") == 0) {
usage();
}

if (strcmp(argv[i], "-version") == 0) {
fprintf(stderr, "vncconfig (TigerVNC) %s\n", PACKAGE_VERSION);
exit(0);
}

break;
}

Expand Down
10 changes: 9 additions & 1 deletion unix/vncpasswd/vncpasswd.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,15 @@ int main(int argc, char** argv)
fname[0] = '\0';

for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "-q") == 0) { // allowed for backwards compatibility
if ((strcmp(argv[i], "-h") == 0) ||
(strcmp(argv[i], "--help") == 0)) {
usage();
} else if ((strcmp(argv[i], "-v") == 0) ||
(strcmp(argv[i], "--version") == 0)) {
fprintf(stderr, "vncpasswd (TigerVNC) %s\n", PACKAGE_VERSION);
exit(0);
} else if (strcmp(argv[i], "-q") == 0) {
// allowed for backwards compatibility
} else if (strncmp(argv[i], "-f", 2) == 0) {
return encrypt_pipe();
} else if (argv[i][0] == '-') {
Expand Down
6 changes: 6 additions & 0 deletions unix/x0vncserver/x0vncserver.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,12 @@ int main(int argc, char** argv)
continue;
}

if (strcmp(argv[i], "-h") == 0 ||
strcmp(argv[i], "-help") == 0 ||
strcmp(argv[i], "--help") == 0) {
usage();
}

if (strcmp(argv[i], "-v") == 0 ||
strcmp(argv[i], "-version") == 0 ||
strcmp(argv[i], "--version") == 0) {
Expand Down
11 changes: 11 additions & 0 deletions vncviewer/vncviewer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,17 @@ int main(int argc, char** argv)
continue;
}

if (strcmp(argv[i], "-h") == 0 ||
strcmp(argv[i], "--help") == 0) {
usage(argv[0]);
}

if (strcmp(argv[i], "-v") == 0 ||
strcmp(argv[i], "--version") == 0) {
/* We already print version on every start */
return 0;
}

if (argv[i][0] == '-')
usage(argv[0]);

Expand Down

0 comments on commit fbe098a

Please sign in to comment.