r""" Easily create a trivial completer for a command. Takes either a list of completions, or all completions in string (that will be split on whitespace). Example:: [d:\ipython]|1> import ipy_completers [d:\ipython]|2> ipy_completers.quick_completer('foo', ['bar','baz'
(cmd, completions)
| 185 | #----------------------------------------------------------------------------- |
| 186 | |
| 187 | def quick_completer(cmd, completions): |
| 188 | r""" Easily create a trivial completer for a command. |
| 189 | |
| 190 | Takes either a list of completions, or all completions in string (that will |
| 191 | be split on whitespace). |
| 192 | |
| 193 | Example:: |
| 194 | |
| 195 | [d:\ipython]|1> import ipy_completers |
| 196 | [d:\ipython]|2> ipy_completers.quick_completer('foo', ['bar','baz']) |
| 197 | [d:\ipython]|3> foo b<TAB> |
| 198 | bar baz |
| 199 | [d:\ipython]|3> foo ba |
| 200 | """ |
| 201 | |
| 202 | if isinstance(completions, str): |
| 203 | completions = completions.split() |
| 204 | |
| 205 | def do_complete(self, event): |
| 206 | return completions |
| 207 | |
| 208 | get_ipython().set_hook('complete_command',do_complete, str_key = cmd) |
| 209 | |
| 210 | def module_completion(line): |
| 211 | """ |
nothing calls this directly
no test coverage detected