mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-01 03:22:48 -05:00
Don't print long usage messages on a command-line error.
In the course of debugging the command-line argument refactoring in previous commits, I found I wasn't quite sure whether PSCP thought I'd given it too many arguments, or too few, because it didn't print an error message saying which: it just printed its giant usage message. Over the last few years I've come to the belief that this is Just Wrong anyway. Printing the whole of a giant help message should only be done when the user asked for it: otherwise, print a short and to-the-point error, and maybe _suggest_ how to get help, but scrolling everything else off the user's screen is not a good response to a typo. I wrote this thought up more fully last year: https://www.chiark.greenend.org.uk/~sgtatham/quasiblog/stop-helping/ So, time to practise what I preach! The PuTTY tools now follow the 'Stop helping!' principle. You can get full help by saying --help. Also, when we do print the help, we now exit(0) rather than exit(1), because there's no reason to report failure: we successfully did what the user asked us for.
This commit is contained in:
@ -189,7 +189,6 @@ static void usage(void)
|
||||
printf(" control what happens when a log file already exists\n");
|
||||
printf(" -shareexists\n");
|
||||
printf(" test whether a connection-sharing upstream exists\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void version(void)
|
||||
@ -350,6 +349,7 @@ int main(int argc, char **argv)
|
||||
version();
|
||||
} else if (!strcmp(p, "--help")) {
|
||||
usage();
|
||||
exit(0);
|
||||
} else if (!strcmp(p, "-pgpfp")) {
|
||||
pgp_fingerprints();
|
||||
exit(1);
|
||||
@ -395,7 +395,10 @@ int main(int argc, char **argv)
|
||||
return 1;
|
||||
|
||||
if (!cmdline_host_ok(conf)) {
|
||||
usage();
|
||||
fprintf(stderr, "plink: no valid host name provided\n"
|
||||
"try \"plink --help\" for help\n");
|
||||
cmdline_arg_list_free(arglist);
|
||||
return 1;
|
||||
}
|
||||
|
||||
prepare_session(conf);
|
||||
|
Reference in New Issue
Block a user