@@ -6,13 +6,14 @@ use crate::cli::i18n::texts;
66use crate :: cli:: ui:: { error, highlight, info, success} ;
77use crate :: config:: get_app_config_path;
88use crate :: error:: AppError ;
9- use crate :: services:: ProviderService ;
109use crate :: services:: ConfigService ;
10+ use crate :: services:: ProviderService ;
1111
12- use super :: utils:: { get_state, pause} ;
12+ use super :: utils:: { clear_screen , get_state, pause} ;
1313
1414pub fn manage_config_menu ( app_type : & AppType ) -> Result < ( ) , AppError > {
1515 loop {
16+ clear_screen ( ) ;
1617 println ! ( "\n {}" , highlight( texts:: config_management( ) ) ) ;
1718 println ! ( "{}" , "─" . repeat( 60 ) ) ;
1819
@@ -67,6 +68,7 @@ pub fn manage_config_menu(app_type: &AppType) -> Result<(), AppError> {
6768}
6869
6970fn edit_common_config_snippet_interactive ( app_type : & AppType ) -> Result < ( ) , AppError > {
71+ clear_screen ( ) ;
7072 println ! (
7173 "\n {}" ,
7274 highlight(
@@ -95,7 +97,11 @@ fn edit_common_config_snippet_interactive(app_type: &AppType) -> Result<(), AppE
9597 loop {
9698 println ! (
9799 "\n {}" ,
98- info( & format!( "{} ({})" , texts:: opening_external_editor( ) , field_name) )
100+ info( & format!(
101+ "{} ({})" ,
102+ texts:: opening_external_editor( ) ,
103+ field_name
104+ ) )
99105 ) ;
100106
101107 let edited = match open_external_editor ( & initial) {
@@ -119,7 +125,10 @@ fn edit_common_config_snippet_interactive(app_type: &AppType) -> Result<(), AppE
119125 let value: serde_json:: Value = match serde_json:: from_str ( & edited) {
120126 Ok ( v) => v,
121127 Err ( e) => {
122- println ! ( "\n {}" , error( & format!( "{}: {}" , texts:: invalid_json_syntax( ) , e) ) ) ;
128+ println ! (
129+ "\n {}" ,
130+ error( & format!( "{}: {}" , texts:: invalid_json_syntax( ) , e) )
131+ ) ;
123132 if !retry_prompt ( ) ? {
124133 return Ok ( ( ) ) ;
125134 }
@@ -177,7 +186,10 @@ fn edit_common_config_snippet_interactive(app_type: &AppType) -> Result<(), AppE
177186 if apply {
178187 let current_id = ProviderService :: current ( & state, app_type. clone ( ) ) ?;
179188 if current_id. trim ( ) . is_empty ( ) {
180- println ! ( "{}" , info( texts:: common_config_snippet_no_current_provider( ) ) ) ;
189+ println ! (
190+ "{}" ,
191+ info( texts:: common_config_snippet_no_current_provider( ) )
192+ ) ;
181193 } else {
182194 ProviderService :: switch ( & state, app_type. clone ( ) , & current_id) ?;
183195 println ! ( "{}" , success( texts:: common_config_snippet_applied( ) ) ) ;
@@ -203,6 +215,7 @@ fn open_external_editor(initial_content: &str) -> Result<String, AppError> {
203215}
204216
205217fn show_config_path_interactive ( ) -> Result < ( ) , AppError > {
218+ clear_screen ( ) ;
206219 let config_path = get_app_config_path ( ) ;
207220 let config_dir = config_path. parent ( ) . unwrap_or ( & config_path) ;
208221
@@ -235,6 +248,7 @@ fn show_config_path_interactive() -> Result<(), AppError> {
235248}
236249
237250fn show_full_config_interactive ( ) -> Result < ( ) , AppError > {
251+ clear_screen ( ) ;
238252 let config = MultiAppConfig :: load ( ) ?;
239253 let json = serde_json:: to_string_pretty ( & config)
240254 . map_err ( |e| AppError :: Message ( format ! ( "Failed to serialize config: {}" , e) ) ) ?;
@@ -251,6 +265,7 @@ fn show_full_config_interactive() -> Result<(), AppError> {
251265}
252266
253267fn export_config_interactive ( path : & str ) -> Result < ( ) , AppError > {
268+ clear_screen ( ) ;
254269 let target_path = Path :: new ( path) ;
255270
256271 if target_path. exists ( ) {
@@ -274,6 +289,7 @@ fn export_config_interactive(path: &str) -> Result<(), AppError> {
274289}
275290
276291fn import_config_interactive ( path : & str ) -> Result < ( ) , AppError > {
292+ clear_screen ( ) ;
277293 let file_path = Path :: new ( path) ;
278294
279295 if !file_path. exists ( ) {
@@ -301,6 +317,7 @@ fn import_config_interactive(path: &str) -> Result<(), AppError> {
301317}
302318
303319fn backup_config_interactive ( ) -> Result < ( ) , AppError > {
320+ clear_screen ( ) ;
304321 println ! (
305322 "\n {}" ,
306323 highlight( texts:: config_backup( ) . trim_start_matches( "💾 " ) )
@@ -342,6 +359,7 @@ fn backup_config_interactive() -> Result<(), AppError> {
342359}
343360
344361fn restore_config_interactive ( ) -> Result < ( ) , AppError > {
362+ clear_screen ( ) ;
345363 println ! (
346364 "\n {}" ,
347365 highlight( texts:: config_restore( ) . trim_start_matches( "♻️ " ) )
@@ -415,6 +433,7 @@ fn restore_config_interactive() -> Result<(), AppError> {
415433}
416434
417435fn validate_config_interactive ( ) -> Result < ( ) , AppError > {
436+ clear_screen ( ) ;
418437 let config_path = get_app_config_path ( ) ;
419438
420439 println ! (
@@ -466,6 +485,7 @@ fn validate_config_interactive() -> Result<(), AppError> {
466485}
467486
468487fn reset_config_interactive ( ) -> Result < ( ) , AppError > {
488+ clear_screen ( ) ;
469489 let confirm = Confirm :: new ( texts:: confirm_reset ( ) )
470490 . with_default ( false )
471491 . prompt ( )
0 commit comments