From cef5feaae1d2472e2d2b5090d680dd3d7289d76d Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sat, 8 Jun 2013 13:56:03 -0500 Subject: split out config handling --- bin/reply | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'bin') 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 $/; @@ -52,7 +47,7 @@ if (!-e $cfg) { close $fh; } else { - warn "Couldn't write to $cfg"; + warn "Couldn't write to $file"; %args = (); } } -- cgit v1.2.3-54-g00ecf