| 34 | '''hint('''''string''''')''' returns a help message providing some information about an incomplete command (incomplete in the sense that not all possible arguments are yet given). This includes a list of the requested arguments and default-values (if any). If there's a description of the command, it is displayed too. |
| 35 | |
| 36 | If ''string'' doesn't describe a unique !ConsoleCommand, hint returns a list of possible commands matching the already given fragment. It also returns a list of possible arguments if there's an [wiki:ArgumentCompleter] declared for the current argument. |
| 37 | |
| 38 | * Example 1 (function description, argument list, default values): |
| 39 | {{{ |
| 40 | class MyClass |
| 41 | { |
| 42 | static void myfunction(int value, bool condition, const std::string& name); |
| 43 | }; |
| 44 | |
| 45 | SetConsoleCommand(MyClass, myfunction, true) |
| 46 | .defaultValue(1, false) // 1 refers to the second argument (condition) |
| 47 | .defaultValue(2, "Default") // 2 refers to the third argument (name) |
| 48 | .description("This is a useless testfunction!"); |
| 49 | |
| 50 | // Get the hint: |
| 51 | CommandExecutor::hint("MyClass myfunction"); |
| 52 | |
| 53 | // Output: |
| 54 | > This is a useless testfunction! |
| 55 | > myfunction: {int} [bool=false] [string=Default] |
| 56 | }}} |
| 57 | |
| 58 | * Example 2 (possible classes and functions, possible arguments): |
| 59 | {{{ |
| 60 | class MyClass |
| 61 | { |
| 62 | static void myfunction(int value, bool condition, const std::string& name); |
| 63 | }; |
| 64 | |
| 65 | SetConsoleCommand(MyClass, myfunction, true) |
| 66 | .defaultValue(1, false) // 1 refers to the second argument (condition) |
| 67 | .defaultValue(2, "Default") // 2 refers to the third argument (name) |
| 68 | .description("This is a useless testfunction!") |
| 69 | .argumentCompleter(2, autocompletion::mynames()); // argument completion for the name |
| 70 | |
| 71 | // First try an empty string: We get a list of all possible classes and functions |
| 72 | CommandExecutor::hint(""); |
| 73 | > myfunction |
| 74 | > MyClass |
| 75 | |
| 76 | // Now start typing the classname: We get a list of all possible |
| 77 | // classnames (only MyClass in our example) |
| 78 | CommandExecutor::hint("mycl"); |
| 79 | > MyClasses |
| 80 | |
| 81 | // We've finished the classname, now we get a list of all functions |
| 82 | // of this class (only myfunction in our example) |
| 83 | CommandExecutor::hint("MyClass "); |
| 84 | > myfunction |
| 85 | |
| 86 | // There's still only one possible function: |
| 87 | CommandExecutor::hint("MyClass myfunc"); |
| 88 | > myfunction |
| 89 | |
| 90 | // Now we get the hint from example 1 |
| 91 | CommandExecutor::hint("MyClass myfunction "); |
| 92 | > This is a useless testfunction! |
| 93 | > myfunction: {int} [bool=false] [string=Default] |
| 94 | |
| 95 | // As soon as we start typing the third argument (notice the space after the |
| 96 | // second argument) we get a list of all possible arguments for "name" because |
| 97 | // we've added an ArgumentCompletor: |
| 98 | CommandExecutor::hint("MyClass myfunction 10 true "); |
| 99 | > Adam Bernd Claude Default Eric Elton Fred Hank |
| 100 | |
| 101 | // We start typing the third argument, the list of possible arguments reduces |
| 102 | // to arguments starting with the given letter: |
| 103 | CommandExecutor::hint("MyClass myfunction 10 true e"); |
| 104 | > Eric Elton |
| 105 | |
| 106 | // We type another letter and the list reduces even more: |
| 107 | CommandExecutor::hint("MyClass myfunction 10 true er"); |
| 108 | > Eric |
| 109 | }}} |
| 110 | |