4
4
import sys
5
5
6
6
from handlers .c import CHandler
7
- from handlers .python import PythonHandler , Python2Handler
7
+ from handlers .cpp import CPPHandler
8
+ from handlers .java import JavaHandler
9
+ from handlers .python import Python2Handler , PythonHandler
8
10
from handlers .shell import BashShellHandler , ShellHandler , ZshShellHandler
11
+ from util import reverse_dict
9
12
10
- handlers = {
11
- "--bash" : BashShellHandler ,
12
- "--c" : CHandler ,
13
- "--python" : PythonHandler ,
14
- "--py" : PythonHandler ,
15
- "--py2" : Python2Handler ,
16
- "--python2" : Python2Handler ,
17
- "--sh" : ShellHandler ,
18
- "--zsh" : ZshShellHandler ,
13
+ handlers_unwrapped = {
14
+ BashShellHandler : [ "--bash" ] ,
15
+ CHandler : [ "--c" ] ,
16
+ CPPHandler : [ "--cpp" , "--c++" , "--cplusplus" ] ,
17
+ JavaHandler : [ "--java" ] ,
18
+ PythonHandler : [ "--python" , "--python3" , "--py" , "--py3" ] ,
19
+ Python2Handler : [ "--python2" , "--py2" ] ,
20
+ ShellHandler : [ "--sh" ] ,
21
+ ZshShellHandler : [ "--zsh" ]
19
22
}
23
+ handlers = reverse_dict (handlers_unwrapped )
20
24
21
25
22
26
def main (args = None ):
@@ -35,13 +39,13 @@ def main(args=None):
35
39
help = "Give the stored file the speified name (does not do anything without --keep)" ,
36
40
default = "script" ,
37
41
)
38
- for argname , handler in handlers .items ():
42
+ for handler , argnames in handlers_unwrapped .items ():
39
43
parser .add_argument (
40
- argname , action = "store_true" , default = None , help = handler .__doc__
44
+ * argnames , action = "store_true" , default = None , help = handler .__doc__
41
45
)
42
46
ns = parser .parse_args (args )
43
47
parsed_dict = {
44
- argname .split ("-" )[- 1 ]: getattr (ns , argname .split ("-" )[- 1 ])
48
+ argname .split ("-" )[- 1 ]: getattr (ns , argname .split ("-" )[- 1 ], None )
45
49
for argname in handlers .keys ()
46
50
}
47
51
parse_count = [bool (val ) for name , val in parsed_dict .items ()].count (True )
0 commit comments