Show More
@@ -16,6 +16,30 b' import glob,os,shlex,sys' | |||||
16 |
|
16 | |||
17 | ip = IPython.ipapi.get() |
|
17 | ip = IPython.ipapi.get() | |
18 |
|
18 | |||
|
19 | def vcs_completer(commands, event): | |||
|
20 | """ utility to make writing typical version control app completers easier | |||
|
21 | ||||
|
22 | VCS command line apps typically have the format: | |||
|
23 | ||||
|
24 | [sudo ]PROGNAME [help] [command] file file... | |||
|
25 | ||||
|
26 | """ | |||
|
27 | ||||
|
28 | ||||
|
29 | cmd_param = event.line.split() | |||
|
30 | if event.line.endswith(' '): | |||
|
31 | cmd_param.append('') | |||
|
32 | ||||
|
33 | if cmd_param[0] == 'sudo': | |||
|
34 | cmd_param = cmd_param[1:] | |||
|
35 | ||||
|
36 | if len(cmd_param) == 2 or 'help' in cmd_param: | |||
|
37 | return commands.split() | |||
|
38 | ||||
|
39 | return ip.IP.Completer.file_matches(event.symbol) | |||
|
40 | ||||
|
41 | ||||
|
42 | ||||
19 | def apt_completers(self, event): |
|
43 | def apt_completers(self, event): | |
20 | """ This should return a list of strings with possible completions. |
|
44 | """ This should return a list of strings with possible completions. | |
21 |
|
45 | |||
@@ -83,11 +107,7 b' status stat st switch sw unlock update' | |||||
83 | """ |
|
107 | """ | |
84 |
|
108 | |||
85 | def svn_completer(self,event): |
|
109 | def svn_completer(self,event): | |
86 | if len((event.line + 'placeholder').split()) > 2: |
|
110 | return vcs_completer(svn_commands, event) | |
87 | # the rest are probably file names |
|
|||
88 | return ip.IP.Completer.file_matches(event.symbol) |
|
|||
89 |
|
||||
90 | return svn_commands.split() |
|
|||
91 |
|
111 | |||
92 | ip.set_hook('complete_command', svn_completer, str_key = 'svn') |
|
112 | ip.set_hook('complete_command', svn_completer, str_key = 'svn') | |
93 |
|
113 | |||
@@ -104,11 +124,8 b' version' | |||||
104 |
|
124 | |||
105 | def hg_completer(self,event): |
|
125 | def hg_completer(self,event): | |
106 | """ Completer for mercurial commands """ |
|
126 | """ Completer for mercurial commands """ | |
107 | if len((event.line + 'placeholder').split()) > 2: |
|
|||
108 | # the rest are probably file names |
|
|||
109 | return ip.IP.Completer.file_matches(event.symbol) |
|
|||
110 |
|
127 | |||
111 |
return hg_commands |
|
128 | return vcs_completer(hg_commands, event) | |
112 |
|
129 | |||
113 | ip.set_hook('complete_command', hg_completer, str_key = 'hg') |
|
130 | ip.set_hook('complete_command', hg_completer, str_key = 'hg') | |
114 |
|
131 |
@@ -1,3 +1,8 b'' | |||||
|
1 | 2006-11-27 Ville Vainio <vivainio@gmail.com> | |||
|
2 | ||||
|
3 | * ipy_stock_completers.py: Clean up svn and hg completers | |||
|
4 | by using a common vcs_completer. | |||
|
5 | ||||
1 | 2006-11-26 Ville Vainio <vivainio@gmail.com> |
|
6 | 2006-11-26 Ville Vainio <vivainio@gmail.com> | |
2 |
|
7 | |||
3 | * Remove ipconfig and %config; you should use _ip.options structure |
|
8 | * Remove ipconfig and %config; you should use _ip.options structure |
General Comments 0
You need to be logged in to leave comments.
Login now