@@ -45,20 +45,41 @@ function command( repl ) {
4545	* 
4646	* @private  
4747	* @param  {string } action - action name 
48+ 	* @param  {Array<Object> } [keys] - list of keys 
4849	* @returns  {void } 
4950	*/ 
50- 	function  onCommand (  action  )  { 
51- 		if  (  ! isString (  action  )  )  { 
52- 			repl . _ostream . write (  format (  'Error: invalid argument. First argument must be a string. Value: `%s`.' ,  action  )  ) ; 
51+ 	function  onCommand ( )  { 
52+ 		var  action ; 
53+ 		var  nargs ; 
54+ 		var  keys ; 
55+ 
56+ 		nargs  =  arguments . length ; 
57+ 		if  (  nargs  ===  0  )  { 
58+ 			repl . _ostream . write (  'Error: invalid argument. First argument must be an action name.\n'  ) ; 
5359			return ; 
5460		} 
55- 		if  (  ! contains (  ACTIONS ,  action  )  )  { 
56- 			repl . _ostream . write (  format (  'Error: invalid argument. First argument must be a valid action name. Value: `%s`.' ,  action  )  ) ; 
61+ 		action  =  arguments [  0  ] ; 
62+ 		if  (  nargs  ===  1  )  { 
63+ 			if  (  ! isString (  action  )  )  { 
64+ 				repl . _ostream . write (  format (  'Error: invalid argument. First argument must be a string. Value: `%s`.\n' ,  action  )  ) ; 
65+ 				return ; 
66+ 			} 
67+ 			if  (  ! contains (  ACTIONS ,  action  )  )  { 
68+ 				repl . _ostream . write (  format (  'Error: invalid argument. First argument must be a valid action name. Value: `%s`.\n' ,  action  )  ) ; 
69+ 				return ; 
70+ 			} 
71+ 			repl . _ostream . write (  'Listening for keypresses...'  ) ; 
72+ 			repl . _isCapturingKeybinding  =  true ; 
73+ 			repl . _targetAction  =  action ; 
5774			return ; 
5875		} 
59- 		repl . _ostream . write (  'Listening for keypresses...'  ) ; 
60- 		repl . _isCapturingKeybinding  =  true ; 
61- 		repl . _targetAction  =  action ; 
76+ 		keys  =  arguments [  1  ] ; 
77+ 		try  { 
78+ 			repl . setKeybinding (  action ,  keys  ) ; 
79+ 			repl . _ostream . write (  format (  '\nSuccessfully set keybindings for action `%s`.\n' ,  action  )  ) ; 
80+ 		}  catch  (  err  )  { 
81+ 			repl . _ostream . write (  format (  'Error: %s\n' ,  err . message  )  ) ; 
82+ 		} 
6283	} 
6384} 
6485
0 commit comments