@@ -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"
@@ -216,7 +216,7 @@ mod tests {
216216
217217 // testing
218218 let result = std:: panic:: catch_unwind ( || {
219- let loaded_config = KeyConfig :: init ( ) . unwrap ( ) ;
219+ let loaded_config = KeyConfig :: init ( None , None ) . unwrap ( ) ;
220220 assert_eq ! (
221221 loaded_config. keys. move_down,
222222 KeysList :: default ( ) . move_down
@@ -231,7 +231,7 @@ mod tests {
231231 & original_key_symbols_path,
232232 )
233233 . unwrap ( ) ;
234- let loaded_config = KeyConfig :: init ( ) . unwrap ( ) ;
234+ let loaded_config = KeyConfig :: init ( None , None ) . unwrap ( ) ;
235235 assert_eq ! (
236236 loaded_config. keys. move_down,
237237 KeysList :: default ( ) . move_down
@@ -243,7 +243,7 @@ mod tests {
243243 & original_key_list_path,
244244 )
245245 . unwrap ( ) ;
246- let loaded_config = KeyConfig :: init ( ) . unwrap ( ) ;
246+ let loaded_config = KeyConfig :: init ( None , None ) . unwrap ( ) ;
247247 assert_eq ! (
248248 loaded_config. keys. move_down,
249249 GituiKeyEvent :: new(
@@ -254,7 +254,7 @@ mod tests {
254254 assert_eq ! ( loaded_config. symbols. esc, "Esc" ) ;
255255
256256 fs:: remove_file ( & original_key_symbols_path) . unwrap ( ) ;
257- let loaded_config = KeyConfig :: init ( ) . unwrap ( ) ;
257+ let loaded_config = KeyConfig :: init ( None , None ) . unwrap ( ) ;
258258 assert_eq ! (
259259 loaded_config. keys. move_down,
260260 GituiKeyEvent :: new(
0 commit comments