File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed
Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -293,7 +293,14 @@ impl Config {
293293 ///
294294 pub fn read ( custom_config_path : Option < PathBuf > ) -> Self {
295295 let mut content = String :: new ( ) ;
296- let config_path = custom_config_path. unwrap_or_else ( default_config_path) ;
296+ let config_path = custom_config_path. unwrap_or_else ( || {
297+ let path = default_config_path ( ) ;
298+ match path. exists ( ) {
299+ true => path,
300+ false => old_default_config_path ( ) ,
301+ }
302+ } ) ;
303+
297304 if config_path. exists ( ) {
298305 content = match fs:: read_to_string ( config_path) {
299306 Ok ( content) => content,
@@ -315,6 +322,14 @@ impl Config {
315322
316323/// Constructs default path to config toml
317324pub fn default_config_path ( ) -> PathBuf {
325+ let Some ( mut config_path) = dirs:: config_dir ( ) else {
326+ panic ! ( "Could not infer config file path." ) ;
327+ } ;
328+ config_path. push ( ".rustscan.toml" ) ;
329+ config_path
330+ }
331+
332+ pub fn old_default_config_path ( ) -> PathBuf {
318333 let Some ( mut config_path) = dirs:: home_dir ( ) else {
319334 panic ! ( "Could not infer config file path." ) ;
320335 } ;
Original file line number Diff line number Diff line change @@ -219,6 +219,17 @@ The Modern Day Port Scanner."#;
219219 opts. greppable,
220220 opts. accessible
221221 ) ;
222+
223+ if opts. config_path . is_none ( ) {
224+ let old_config_path = input:: old_default_config_path ( ) ;
225+ detail ! (
226+ format!(
227+ "For backwards compatibility, the config file may also be at {old_config_path:?}"
228+ ) ,
229+ opts. greppable,
230+ opts. accessible
231+ ) ;
232+ }
222233}
223234
224235#[ cfg( unix) ]
You can’t perform that action at this time.
0 commit comments