@@ -10,7 +10,7 @@ mod url_processor;
1010
1111use crate :: analyzer:: process_directory;
1212use crate :: cli:: Cli ;
13- use crate :: config:: { get_config_path, load_config, load_repo_config, save_repo_config, RepoConfig } ;
13+ use crate :: config:: { get_config_path, load_config, load_repo_config, save_repo_config, save_config , RepoConfig } ;
1414use crate :: git_processor:: GitProcessor ;
1515use crate :: url_processor:: UrlProcessor ;
1616use std:: fs;
@@ -33,7 +33,7 @@ fn has_custom_options(args: &Cli) -> bool {
3333}
3434
3535fn main ( ) -> anyhow:: Result < ( ) > {
36- let config = load_config ( ) ?;
36+ let mut config = load_config ( ) ?;
3737 let mut args = Cli :: parse_with_config ( & config) ?;
3838
3939 if args. config_path {
@@ -59,20 +59,55 @@ fn main() -> anyhow::Result<()> {
5959 let repo_config = create_repo_config_from_args ( & args) ;
6060 save_repo_config ( & glimpse_file, & repo_config) ?;
6161 println ! ( "Configuration saved to {}" , glimpse_file. display( ) ) ;
62+
63+ // If the user explicitly saved a config, remove this directory from the skipped list
64+ if let Ok ( canonical_root) = std:: fs:: canonicalize ( & root_dir) {
65+ let root_str = canonical_root. to_string_lossy ( ) . to_string ( ) ;
66+ if let Some ( pos) = config
67+ . skipped_prompt_repos
68+ . iter ( )
69+ . position ( |p| p == & root_str)
70+ {
71+ config. skipped_prompt_repos . remove ( pos) ;
72+ save_config ( & config) ?;
73+ }
74+ }
6275 } else if glimpse_file. exists ( ) {
6376 println ! ( "Loading configuration from {}" , glimpse_file. display( ) ) ;
6477 let repo_config = load_repo_config ( & glimpse_file) ?;
6578 apply_repo_config ( & mut args, & repo_config) ;
6679 } else if has_custom_options ( & args) {
67- print ! ( "Would you like to save these options as defaults for this directory? (y/n): " ) ;
68- io:: stdout ( ) . flush ( ) ?;
69- let mut response = String :: new ( ) ;
70- io:: stdin ( ) . read_line ( & mut response) ?;
71-
72- if response. trim ( ) . to_lowercase ( ) == "y" {
73- let repo_config = create_repo_config_from_args ( & args) ;
74- save_repo_config ( & glimpse_file, & repo_config) ?;
75- println ! ( "Configuration saved to {}" , glimpse_file. display( ) ) ;
80+ // Determine canonical root directory path for consistent tracking
81+ let canonical_root = std:: fs:: canonicalize ( & root_dir) . unwrap_or ( root_dir. clone ( ) ) ;
82+ let root_str = canonical_root. to_string_lossy ( ) . to_string ( ) ;
83+
84+ if !config. skipped_prompt_repos . contains ( & root_str) {
85+ print ! (
86+ "Would you like to save these options as defaults for this directory? (y/n): "
87+ ) ;
88+ io:: stdout ( ) . flush ( ) ?;
89+ let mut response = String :: new ( ) ;
90+ io:: stdin ( ) . read_line ( & mut response) ?;
91+
92+ if response. trim ( ) . to_lowercase ( ) == "y" {
93+ let repo_config = create_repo_config_from_args ( & args) ;
94+ save_repo_config ( & glimpse_file, & repo_config) ?;
95+ println ! ( "Configuration saved to {}" , glimpse_file. display( ) ) ;
96+
97+ // In case it was previously skipped, remove from skipped list
98+ if let Some ( pos) = config
99+ . skipped_prompt_repos
100+ . iter ( )
101+ . position ( |p| p == & root_str)
102+ {
103+ config. skipped_prompt_repos . remove ( pos) ;
104+ save_config ( & config) ?;
105+ }
106+ } else {
107+ // Record that user declined for this project
108+ config. skipped_prompt_repos . push ( root_str) ;
109+ save_config ( & config) ?;
110+ }
76111 }
77112 }
78113 }
0 commit comments