| 1 | # Miscellaneous Features |
| 2 | |
| 3 | ## Timer {: #Timer } |
| 4 | |
| 5 | Turn the timer setting on, and `cmd2` will show the wall time it takes for each command to execute. |
| 6 | |
| 7 | ## Exiting |
| 8 | |
| 9 | Like many shell applications, `cmd2` applications can be exited by pressing `Ctrl-D` on an empty |
| 10 | line, or by executing the `quit` command. |
| 11 | |
| 12 | ## select |
| 13 | |
| 14 | Presents numbered options to user, as bash `select`. |
| 15 | |
| 16 | `app.select` is called from within a method (not by the user directly; it is `app.select`, not |
| 17 | `app.do_select`). |
| 18 | |
| 19 | ::: cmd2.Cmd.select |
| 20 | |
| 21 | ```py |
| 22 | def do_eat(self, arg): |
| 23 | sauce = self.select('sweet salty', 'Sauce? ') |
| 24 | result = '{food} with {sauce} sauce, yum!' |
| 25 | result = result.format(food=arg, sauce=sauce) |
| 26 | self.stdout.write(result + '\n') |
| 27 | ``` |
| 28 | |
| 29 | ```text |
| 30 | (Cmd) eat wheaties |
| 31 | 1. sweet |
| 32 | 2. salty |
| 33 | Sauce? 2 |
| 34 | wheaties with salty sauce, yum! |
| 35 | ``` |
| 36 | |
| 37 | See the `do_eat` method in the |
| 38 | [read_input.py](https://github.com/python-cmd2/cmd2/blob/main/examples/read_input.py) file for a |
| 39 | example of how to use `select. |
| 40 | |
| 41 | ## Disabling Commands |
| 42 | |
| 43 | `cmd2` supports disabling commands during runtime. This is useful if certain commands should only be |
| 44 | available when the application is in a specific state. When a command is disabled, it will not show |
| 45 | up in the help menu or tab complete. If a user tries to run the command, a command-specific message |
| 46 | supplied by the developer will be printed. The following functions support this feature. |
| 47 | |
| 48 | - [enable_command][cmd2.Cmd.enable_command] : Enable an individual command |
| 49 | - [enable_category][cmd2.Cmd.enable_category] : Enable an entire category of commands |
| 50 | - [disable_command][cmd2.Cmd.disable_command] : Disable an individual command and set the message |
| 51 | that will print when this command is run or help is called on it while disabled |
| 52 | - [disable_category][cmd2.Cmd.disable_category] : Disable an entire category of commands and set the |
| 53 | message that will print when anything in this category is run or help is called on it while |
| 54 | disabled |
| 55 | |
| 56 | See the definitions of these functions for descriptions of their arguments. |
| 57 | |
| 58 | See the `do_enable_commands()` and `do_disable_commands()` functions in the |
| 59 | [help_categories.py](https://github.com/python-cmd2/cmd2/blob/main/examples/help_categories.py) |
| 60 | example for a demonstration. |