File tree 3 files changed +27
-1
lines changed
3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 37
37
LABEL_VERSION = "version"
38
38
LABEL_GROUP = "group"
39
39
LABEL_DEFINE = "define"
40
+ LABEL_EXTENSION = "extension"
40
41
CLI_DICT = "user_dict"
42
+ EXTENSION_DICT = "user_extensions"
41
43
42
44
DEFAULT_CONFIGURATION_DIRNAME = ".%s.cd" % PROGRAM_NAME
43
45
DEFAULT_TEMPLATE_DIRNAME = ".%s.td" % PROGRAM_NAME
Original file line number Diff line number Diff line change @@ -22,7 +22,13 @@ def __init__(self):
22
22
self .options_registry = {}
23
23
24
24
def register_extensions (self , extensions ):
25
- self .extensions .update (extensions )
25
+ for template_type in extensions .keys ():
26
+ if template_type in self .extensions :
27
+ self .extensions [template_type ] = self .extensions [
28
+ template_type
29
+ ].union (extensions [template_type ])
30
+ else :
31
+ self .extensions [template_type ] = extensions [template_type ]
26
32
27
33
def register_options (self , template_types ):
28
34
# need the value of 'template_types'
Original file line number Diff line number Diff line change 12
12
import logging
13
13
import argparse
14
14
import logging .config
15
+ from collections import defaultdict
15
16
16
17
from moban import (
17
18
core ,
@@ -41,6 +42,7 @@ def main():
41
42
options [constants .CLI_DICT ] = handle_custom_variables (
42
43
options .pop (constants .LABEL_DEFINE )
43
44
)
45
+ handle_custom_variables (options .pop (constants .LABEL_EXTENSION ))
44
46
OPTIONS .update (options )
45
47
handle_verbose (options [constants .LABEL_VERBOSE ])
46
48
@@ -155,6 +157,12 @@ def create_parser():
155
157
nargs = "+" ,
156
158
help = "to take a list of VAR=VALUEs" ,
157
159
)
160
+ parser .add_argument (
161
+ "-e" ,
162
+ "--%s" % constants .LABEL_EXTENSION ,
163
+ nargs = "+" ,
164
+ help = "to add an extension to TEMPLATE_TYPE=EXTENSION_NAME" ,
165
+ )
158
166
return parser
159
167
160
168
@@ -265,6 +273,16 @@ def handle_custom_variables(list_of_definitions):
265
273
return custom_data
266
274
267
275
276
+ def handle_custom_extensions (list_of_definitions ):
277
+ user_extensions = defaultdict (set )
278
+ if list_of_definitions :
279
+ for definition in list_of_definitions :
280
+ key , value = definition .split ("=" )
281
+ user_extensions [key ].append (value )
282
+
283
+ core .ENGINES .register_options (user_extensions )
284
+
285
+
268
286
def handle_verbose (verbose_level ):
269
287
if verbose_level > len (LOG_LEVEL ):
270
288
verbose_level = 3
You can’t perform that action at this time.
0 commit comments