Closed van-de-bugger closed 2 years ago
I agree this is weird, but it is as documented:
https://metacpan.org/pod/File::XDG#lookup_config_file
Looks up the configuration file by searching for
./$subdir/$filename
relative to all base directories indicated by$XDG_CONFIG_HOME
and$XDG_CONFIG_DIRS
. If an environment variable is either not set or empty, its default value as defined by the specification is used instead. Returns a Path::Class object.
lookup_config_file takes two arguments, the app-name and the filename so if you use $xdg->lookup_config_file( 'Test', $cfg );
you should get the the file that you intend. That said:
Ok, I see. Probably I didn't read the documentation carefully enough.
However, it is rather strange design decision: The File::XDG
constructor requires app name, this app name is used by config_home
, why it is not used by lookup_config_file
? Why the app name is not used consistently?
Ok, I see. Probably I didn't read the documentation carefully enough.
However, it is rather strange design decision: The
File::XDG
constructor requires app name, this app name is used byconfig_home
, why it is not used bylookup_config_file
? Why the app name is not used consistently?
I agree! I'm not the original designer though just the maintainer, so I am not sure as to the why. I'd like to provide a more sensible interface, but would like to do it in a backward compatible way. One option I initially suggested would be to add methods to do things the more consistent way. Another option would be to provide a more consistent API if the object is constructed in a certain way (passing an api => 2 option perhaps).
use File::XDG;
my $xdg = File::XDG->new( name => 'Test', api => 2 );
# same as File::XDG->new( name => '...', api => 1 )->lookup_config_file( 'Test', 'test.cionf' );
my $path = $xdg->lookup_config_file( 'test.conf' );
I've started #17 to add experimental features for the version 1.00 API that would make these methods not take the app name, among other features. The new API will be opt-in so as to maintain backward compatibility.
I've released #17 as 0.09_01
which can be used to experiment with this new interface.
1.00_01
implements the final-ish form of this new/old API design.
lookup_config_file
does look atconfig_home
: