@@ -2,10 +2,7 @@ use anyhow::{anyhow, Result};
22use crossterm:: event:: { KeyCode , KeyModifiers } ;
33use std:: { fs:: canonicalize, path:: PathBuf , rc:: Rc } ;
44
5- use crate :: {
6- args:: { get_app_config_path, CliArgs } ,
7- strings:: symbol,
8- } ;
5+ use crate :: { args:: get_app_config_path, strings:: symbol} ;
96
107use super :: {
118 key_list:: { GituiKeyEvent , KeysList } ,
@@ -37,8 +34,11 @@ impl KeyConfig {
3734 . map_or_else ( |_| Ok ( symbols_file) , Ok )
3835 }
3936
40- pub fn init ( cli_args : & CliArgs ) -> Result < Self > {
41- let keys = if let Some ( path) = & cli_args. key_bindings_path {
37+ pub fn init (
38+ key_bindings_path : Option < & PathBuf > ,
39+ key_symbols_path : Option < & PathBuf > ,
40+ ) -> Result < Self > {
41+ let keys = if let Some ( path) = key_bindings_path {
4242 if !path. exists ( ) {
4343 return Err ( anyhow ! (
4444 "The custom key bindings file dosen't exists"
@@ -49,7 +49,7 @@ impl KeyConfig {
4949 KeysList :: init ( Self :: get_config_file ( ) ?)
5050 } ;
5151
52- let symbols = if let Some ( path) = & cli_args . key_symbols_path {
52+ let symbols = if let Some ( path) = key_symbols_path {
5353 if !path. exists ( ) {
5454 return Err ( anyhow ! (
5555 "The custom key symbols file dosen't exists"
@@ -208,7 +208,7 @@ mod tests {
208208
209209 // testing
210210 let result = std:: panic:: catch_unwind ( || {
211- let loaded_config = KeyConfig :: init ( ) . unwrap ( ) ;
211+ let loaded_config = KeyConfig :: init ( None , None ) . unwrap ( ) ;
212212 assert_eq ! (
213213 loaded_config. keys. move_down,
214214 KeysList :: default ( ) . move_down
@@ -223,7 +223,7 @@ mod tests {
223223 & original_key_symbols_path,
224224 )
225225 . unwrap ( ) ;
226- let loaded_config = KeyConfig :: init ( ) . unwrap ( ) ;
226+ let loaded_config = KeyConfig :: init ( None , None ) . unwrap ( ) ;
227227 assert_eq ! (
228228 loaded_config. keys. move_down,
229229 KeysList :: default ( ) . move_down
@@ -235,7 +235,7 @@ mod tests {
235235 & original_key_list_path,
236236 )
237237 . unwrap ( ) ;
238- let loaded_config = KeyConfig :: init ( ) . unwrap ( ) ;
238+ let loaded_config = KeyConfig :: init ( None , None ) . unwrap ( ) ;
239239 assert_eq ! (
240240 loaded_config. keys. move_down,
241241 GituiKeyEvent :: new(
@@ -246,7 +246,7 @@ mod tests {
246246 assert_eq ! ( loaded_config. symbols. esc, "Esc" ) ;
247247
248248 fs:: remove_file ( & original_key_symbols_path) . unwrap ( ) ;
249- let loaded_config = KeyConfig :: init ( ) . unwrap ( ) ;
249+ let loaded_config = KeyConfig :: init ( None , None ) . unwrap ( ) ;
250250 assert_eq ! (
251251 loaded_config. keys. move_down,
252252 GituiKeyEvent :: new(
0 commit comments