summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-06-08 13:56:03 -0500
committerJesse Luehrs <doy@tozt.net>2013-06-08 13:56:03 -0500
commitcef5feaae1d2472e2d2b5090d680dd3d7289d76d (patch)
treee89d4503366b970ff9f71cde2e006ac4f8f19ad2 /bin
parent1d7c2a0959a8e91ff3d6ccb279fd6928d397e602 (diff)
downloadreply-cef5feaae1d2472e2d2b5090d680dd3d7289d76d.tar.gz
reply-cef5feaae1d2472e2d2b5090d680dd3d7289d76d.zip
split out config handling
Diffstat (limited to 'bin')
-rw-r--r--bin/reply19
1 files changed, 7 insertions, 12 deletions
diff --git a/bin/reply b/bin/reply
index c4f284c..5572193 100644
--- a/bin/reply
+++ b/bin/reply
@@ -4,11 +4,10 @@ use warnings;
# PODNAME: reply
# ABSTRACT: read, eval, print, loop, yay!
-use File::HomeDir;
-use File::Spec;
use Getopt::Long;
use Reply;
+use Reply::Config;
=head1 SYNOPSIS
@@ -32,17 +31,13 @@ GetOptions(
'help' => sub { usage(0) },
) or usage(1);
-my $cfg = File::Spec->catfile(
- (File::Spec->file_name_is_absolute($cfgfile)
- ? ()
- : (File::HomeDir->my_home)),
- $cfgfile
-);
+my $cfg = Reply::Config->new(file => $cfgfile);
my %args = (config => $cfg);
-if (!-e $cfg) {
- print("$cfg not found. Generating a default...\n");
- if (open my $fh, '>', $cfg) {
+my $file = $cfg->file;
+if (!-e $file) {
+ print("$file not found. Generating a default...\n");
+ if (open my $fh, '>', $file) {
my $contents = do {
local $/;
<DATA>
@@ -52,7 +47,7 @@ if (!-e $cfg) {
close $fh;
}
else {
- warn "Couldn't write to $cfg";
+ warn "Couldn't write to $file";
%args = ();
}
}