diff options
| author | kotfu <kotfu@kotfu.net> | 2020-04-19 16:23:48 -0600 |
|---|---|---|
| committer | kotfu <kotfu@kotfu.net> | 2020-04-19 16:23:48 -0600 |
| commit | 5cb7e38cd236ea94b5915053e48dacda042f2c17 (patch) | |
| tree | 24b5e9a32ccf0e7df795a1ffe791cd692dcad391 | |
| parent | 2ca26a39743e744cd1c77687c8cd1cbe8035a041 (diff) | |
| download | cmd2-git-5cb7e38cd236ea94b5915053e48dacda042f2c17.tar.gz | |
Document help topics not associated with commands
| -rw-r--r-- | dashes-todo.txt | 23 | ||||
| -rw-r--r-- | docs/features/help.rst | 8 | ||||
| -rw-r--r-- | examples/cmds_with_dashes.py | 4 |
3 files changed, 35 insertions, 0 deletions
diff --git a/dashes-todo.txt b/dashes-todo.txt index 514f9545..bece0201 100644 --- a/dashes-todo.txt +++ b/dashes-todo.txt @@ -5,3 +5,26 @@ Things to be done to implement the changes described in - [ ] fix get_help_topics() so it looks in self._help_methods - [ ] fix enabling and disabling commands and categories +- [ ] make get_all_commands() look at the _command_methods dict +- [ ] make get_help_topics() look at _help_methods dict +- [x] add documentation showing how to make help that isn't associated + with a command + + +## Design principles + +The unique thing that identifies a command is not the function, it's the name. +By default the name of the function defines the name of the command. + +Renaming a command is therefore changing the primary identifier of that +command. When you do so, you are messing with everything else that uses that +primary identifier for the command, like hidden and disabled commands. + + + + + +## Documentation Updates + +- self.hidden_commands +- self.disabled_commands diff --git a/docs/features/help.rst b/docs/features/help.rst index 57aa2187..20cee220 100644 --- a/docs/features/help.rst +++ b/docs/features/help.rst @@ -6,6 +6,7 @@ quality or useful that documentation might be. So it is important that you provide good built-in help within your application. Fortunately, ``cmd2`` makes this easy. + Getting Help ------------ @@ -35,6 +36,7 @@ command: optional arguments: -h, --help show this help message and exit + Providing Help -------------- @@ -56,6 +58,12 @@ for command **foo**. This dynamic help is only supported for commands which do not use an ``argparse`` decorator because didn't want different output for ``help cmd`` than for ``cmd -h``. +You can also create help topics that are not associated with any command. +Simply create a method called ``help_mytopic`` which displays the appropriate +information. ``cmd2`` will find this topic and show it in it's own section when +the user runs the built-in ``help`` command. + + Categorizing Commands --------------------- diff --git a/examples/cmds_with_dashes.py b/examples/cmds_with_dashes.py index 3b10c7ad..7ee5d6f8 100644 --- a/examples/cmds_with_dashes.py +++ b/examples/cmds_with_dashes.py @@ -11,6 +11,7 @@ class CmdLineApp(cmd2.Cmd): super().__init__() self.rename_command('speed_up', 'speed-up') self.rename_command('run_pyscript', 'run-pyscript') + self.self_in_py = True def do_speed_up(self, args): self.poutput("going faster") @@ -22,6 +23,9 @@ class CmdLineApp(cmd2.Cmd): """some dochelp on the debug command""" import ipdb; ipdb.set_trace() + def help_mytopic(self): + self.poutput('additional help on a topic that is not a command') + if __name__ == '__main__': import sys |
