Show More
@@ -16,6 +16,30 b' import glob,os,shlex,sys' | |||
|
16 | 16 | |
|
17 | 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 | 43 | def apt_completers(self, event): |
|
20 | 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 | 109 | def svn_completer(self,event): |
|
86 | if len((event.line + 'placeholder').split()) > 2: | |
|
87 | # the rest are probably file names | |
|
88 | return ip.IP.Completer.file_matches(event.symbol) | |
|
89 | ||
|
90 | return svn_commands.split() | |
|
110 | return vcs_completer(svn_commands, event) | |
|
91 | 111 | |
|
92 | 112 | ip.set_hook('complete_command', svn_completer, str_key = 'svn') |
|
93 | 113 | |
@@ -104,11 +124,8 b' version' | |||
|
104 | 124 | |
|
105 | 125 | def hg_completer(self,event): |
|
106 | 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 | 130 | ip.set_hook('complete_command', hg_completer, str_key = 'hg') |
|
114 | 131 |
General Comments 0
You need to be logged in to leave comments.
Login now