Skip to content
This repository has been archived by the owner on Apr 22, 2021. It is now read-only.

Commit

Permalink
Find config at os specific locations
Browse files Browse the repository at this point in the history
  • Loading branch information
mdom committed Mar 1, 2016
1 parent e6a0b3b commit 15e7dbf
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/App/txtnix.pm
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ sub new {
}

$args->{config} =
path( $args->{config} || '~/.config/twtxt/config' );
$args->{config} ? path( $args->{config} ) : $class->_build_config_file;

for (qw(since until)) {
if ( exists $args->{$_} ) {
Expand Down Expand Up @@ -92,6 +92,17 @@ sub _build_ua {
return $ua;
}

sub _build_config_file {
my $dir = path(
$ENV{XDG_CONFIG_HOME} ? $ENV{XDG_CONFIG_HOME}
: $^O eq "MSWin32" ? $ENV{APPDATA}
: $^O eq 'darwin' ? '~/Library/Application Support'
: '~/.config/'
)->child('twtxt');
$dir->mkpath if !$dir->exists;
return $dir->child('config');
}

sub write_config {
my ( $self, $config ) = @_;
$config->write( $self->config, 'utf8' );
Expand Down

0 comments on commit 15e7dbf

Please sign in to comment.