diff options
| author | kmvanbrunt <kmvanbrunt@gmail.com> | 2018-03-29 22:52:05 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-03-29 22:52:05 -0400 |
| commit | 852093899d012939bc405f03c4df446e8e024518 (patch) | |
| tree | 8067c5deaca5fd24a64aae65f53cd4a0d931536a /docs | |
| parent | 28c89a543cba26c8cc8fc310b6b7b914d1660445 (diff) | |
| parent | cd0674fa6894b8f9c6cdf866bc838935a9ee76bb (diff) | |
| download | cmd2-git-852093899d012939bc405f03c4df446e8e024518.tar.gz | |
Merge pull request #329 from python-cmd2/new_quoted_completion
Adding tab completion improvements
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/freefeatures.rst | 10 | ||||
| -rw-r--r-- | docs/requirements.txt | 2 |
2 files changed, 9 insertions, 3 deletions
diff --git a/docs/freefeatures.rst b/docs/freefeatures.rst index 740ea067..8255868c 100644 --- a/docs/freefeatures.rst +++ b/docs/freefeatures.rst @@ -333,8 +333,7 @@ Additionally, it is trivial to add identical file system path completion to your have defined a custom command ``foo`` by implementing the ``do_foo`` method. To enable path completion for the ``foo`` command, then add a line of code similar to the following to your class which inherits from ``cmd2.Cmd``:: - # Make sure you have an "import functools" somewhere at the top - complete_foo = functools.partial(path_complete) + complete_foo = self.path_complete This will effectively define the ``complete_foo`` readline completer method in your class and make it utilize the same path completion logic as the built-in commands. @@ -345,4 +344,9 @@ path completion of directories only for this command by adding a line of code si which inherits from ``cmd2.Cmd``:: # Make sure you have an "import functools" somewhere at the top - complete_bar = functools.partial(path_complete, dir_only=True) + complete_bar = functools.partialmethod(cmd2.Cmd.path_complete, dir_only=True) + + # Since Python 2 does not have functools.partialmethod(), you can achieve the + # same thing by implementing a tab completion function + def complete_bar(self, text, line, begidx, endidx): + return self.path_complete(text, line, begidx, endidx, dir_only=True) diff --git a/docs/requirements.txt b/docs/requirements.txt index b50df7d1..b8cf9271 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -2,3 +2,5 @@ pyparsing six pyperclip contextlib2 +enum34 +subprocess32 |
