Fixed remaining problems with using xdg structure to store configuration files, e.g. key.
This commit is contained in:
+13
-11
@@ -22,15 +22,7 @@ require 5.005;
|
||||
use File::Path qw(make_path);
|
||||
|
||||
|
||||
# Use XDG_CONFIG_HOME or default to ~/.config
|
||||
our $config = ($ENV{'XDG_CONFIG_HOME'} || "$ENV{'HOME'}/.config") . '/ttyverse';
|
||||
# Check if the directory exists; if not, create it
|
||||
unless (-d $config) {
|
||||
eval { make_path($config) };
|
||||
if ($@) {
|
||||
die "Failed to create directory: $@";
|
||||
}
|
||||
}
|
||||
# XDG configuration will be set up in the BEGIN block
|
||||
|
||||
BEGIN {
|
||||
# ONLY STUFF THAT MUST RUN BEFORE INITIALIZATION GOES HERE!
|
||||
@@ -240,10 +232,20 @@ EOF
|
||||
$trendsurl = "${apibase}/trends";
|
||||
}
|
||||
|
||||
# Set up XDG config directory
|
||||
our $config = ($ENV{'XDG_CONFIG_HOME'} || "$ENV{'HOME'}/.config") . '/ttyverse';
|
||||
# Check if the directory exists; if not, create it
|
||||
unless (-d $config) {
|
||||
eval { make_path($config) };
|
||||
if ($@) {
|
||||
die "Failed to create directory: $@";
|
||||
}
|
||||
}
|
||||
|
||||
# try to find an OAuth keyfile if we haven't specified key+secret
|
||||
# no worries if this fails; we could be Basic Auth, after all
|
||||
$whine = (length($keyf)) ? 1 : 0;
|
||||
$keyf ||= "$config key";
|
||||
$keyf ||= "$config/key";
|
||||
$attempted_keyf = $keyf;
|
||||
if (!length($oauthkey) && !length($oauthsecret) # set later
|
||||
&& !length($tokenkey)
|
||||
@@ -1130,7 +1132,7 @@ you use with TTYverse; only one account token can be stored per keyfile. If you
|
||||
have multiple accounts, use -keyf=... to specify different keyfiles. KEEP THESE
|
||||
FILES SECRET.
|
||||
|
||||
** This wizard will overwrite $config/$keyf
|
||||
** This wizard will overwrite $keyf
|
||||
Press RETURN/ENTER to continue or CTRL-C NOW! to abort.
|
||||
EOF
|
||||
$j = <STDIN>;
|
||||
|
||||
Reference in New Issue
Block a user