fix made --help work correctly
This commit is contained in:
+16
-11
@@ -72,18 +72,17 @@ void print_help_and_usage() {
|
|||||||
"Help and usage for Wordle:\n"
|
"Help and usage for Wordle:\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Help:\n"
|
"Help:\n"
|
||||||
"--wordlist <path_to_wordlist_file> ... specify a custom wordlist\n"
|
"--wordlist <path_to_wordlist_file> ........... specify a custom wordlist\n"
|
||||||
" RULES: five characters on each line (no empty lines),\n"
|
" RULES: five characters on each line (no empty lines),\n"
|
||||||
" each new line is separated by '\\n' (Enter/Return)\n"
|
" each new line is separated by '\\n' (Enter/Return)\n"
|
||||||
"--verbose ............................ be verbose (show what the program is doing aka debug info)\n"
|
"--verbose .................................... be verbose (show what the program is doing aka debug info)\n"
|
||||||
"--help ............................... show this help screen\n"
|
"--help ....................................... show this help screen\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Usage:\n"
|
"Usage:\n"
|
||||||
"\n"
|
"\n"
|
||||||
"wordle\n"
|
"wordlec ...................................... starts Wordle with the default wordlist\n"
|
||||||
"=> starts Wordle with the default wordlist\n"
|
"\n"
|
||||||
"wordle --wordlist <path_to_wordlist_file>\n"
|
"wordlec --wordlist <path_to_wordlist_file> ... starts Wordle with a specified wordlist\n"
|
||||||
"=> starts Wordle with a specified wordlist\n"
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,7 +296,7 @@ int argparse(int argc, char *argv[]) {
|
|||||||
|
|
||||||
if (strcmp(argv[i], "--help") == 0) {
|
if (strcmp(argv[i], "--help") == 0) {
|
||||||
print_help_and_usage();
|
print_help_and_usage();
|
||||||
return 0;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -344,7 +343,13 @@ void show_win_lose_message() {
|
|||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
// pass the arguments
|
// pass the arguments
|
||||||
if (argparse(argc, argv) == 1) return 1;
|
int args = argparse(argc, argv);
|
||||||
|
switch (args) {
|
||||||
|
case 1:
|
||||||
|
return 1;
|
||||||
|
case 2:
|
||||||
|
return 0; // --help passed
|
||||||
|
}
|
||||||
|
|
||||||
// prerequisite 1
|
// prerequisite 1
|
||||||
get_random_word(word_to_guess, wordlist_path);
|
get_random_word(word_to_guess, wordlist_path);
|
||||||
|
|||||||
Reference in New Issue
Block a user