diff options
author | Jesse Luehrs <doy@tozt.net> | 2013-06-08 13:56:03 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2013-06-08 13:56:03 -0500 |
commit | cef5feaae1d2472e2d2b5090d680dd3d7289d76d (patch) | |
tree | e89d4503366b970ff9f71cde2e006ac4f8f19ad2 /bin | |
parent | 1d7c2a0959a8e91ff3d6ccb279fd6928d397e602 (diff) | |
download | reply-cef5feaae1d2472e2d2b5090d680dd3d7289d76d.tar.gz reply-cef5feaae1d2472e2d2b5090d680dd3d7289d76d.zip |
split out config handling
Diffstat (limited to 'bin')
-rw-r--r-- | bin/reply | 19 |
1 files changed, 7 insertions, 12 deletions
@@ -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 = (); } } |