File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -294,7 +294,14 @@ impl Config {
294294 ///
295295 pub fn read ( custom_config_path : Option < PathBuf > ) -> Self {
296296 let mut content = String :: new ( ) ;
297- let config_path = custom_config_path. unwrap_or_else ( default_config_path) ;
297+ let config_path = custom_config_path. unwrap_or_else ( || {
298+ let path = default_config_path ( ) ;
299+ match path. exists ( ) {
300+ true => path,
301+ false => old_default_config_path ( ) ,
302+ }
303+ } ) ;
304+
298305 if config_path. exists ( ) {
299306 content = match fs:: read_to_string ( config_path) {
300307 Ok ( content) => content,
@@ -316,6 +323,15 @@ impl Config {
316323
317324/// Constructs default path to config toml
318325pub fn default_config_path ( ) -> PathBuf {
326+ let Some ( mut config_path) = dirs:: config_dir ( ) else {
327+ panic ! ( "Could not infer config file path." ) ;
328+ } ;
329+ config_path. push ( ".rustscan.toml" ) ;
330+ config_path
331+ }
332+
333+ /// Returns the deprecated home directory config path used for backwards compatibility.
334+ pub fn old_default_config_path ( ) -> PathBuf {
319335 let Some ( mut config_path) = dirs:: home_dir ( ) else {
320336 panic ! ( "Could not infer config file path." ) ;
321337 } ;
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