@@ -18,8 +18,10 @@ module.exports = new Extension({
1818 'start_command' : function ( args , tokens ) {
1919 // 1. clone template .xinitrc
2020 var filePath = _cloneTemplate ( this . xinitrcTplPath ) ;
21+ // 1. parse options from args into tokens
22+ var _tokens = _extendTokens ( args , tokens ) ;
2123 // 1. replace tokens in .xinitrc
22- _replaceTokens ( filePath , tokens ) ;
24+ _replaceTokens ( filePath , _tokens ) ;
2325 // 2. return xinit
2426 return 'xinit ' + filePath ;
2527 } ,
@@ -28,6 +30,30 @@ module.exports = new Extension({
2830 } ,
2931} ) ;
3032
33+ /**
34+ * extend the tokens with expected values from args
35+ *
36+ * @param {object } args Arguments provided to this extension
37+ * @param {object } tokens Original tokens for this extension
38+ */
39+ function _extendTokens ( args , tokens ) {
40+ var _tokens = { } ;
41+ // shallow-copy the original tokens object
42+ for ( var key in tokens ) {
43+ _tokens [ key ] = tokens [ key ] ;
44+ }
45+
46+ // copy expected arguments from args to the new tokens object
47+ // defaulting to an emptystring
48+ var expectedKeys = [ 'flags' ] ;
49+ for ( var key of expectedKeys ) {
50+ // prepend keys with a dollar-sign for template-replacement
51+ _tokens [ '$' + key ] = args [ key ] || '' ;
52+ }
53+
54+ return _tokens ;
55+ }
56+
3157/**
3258 * Replace tokens in a file.
3359 *
0 commit comments