summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/Reply/App.pm40
1 files changed, 29 insertions, 11 deletions
diff --git a/lib/Reply/App.pm b/lib/Reply/App.pm
index baeb0e4..66f9adb 100644
--- a/lib/Reply/App.pm
+++ b/lib/Reply/App.pm
@@ -75,17 +75,7 @@ sub run {
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>
- };
- $contents =~ s/use 5.XXX/use $]/;
- print $fh $contents;
- close $fh;
- }
- else {
- warn "Couldn't write to $file";
+ unless ($self->generate_default_config($file)) {
%args = ();
}
}
@@ -99,6 +89,34 @@ sub run {
return 0;
}
+=method generate_default_config($file)
+
+Generates default configuration file as per specified destination.
+
+=cut
+
+sub generate_default_config {
+ my $self = shift;
+ my ($file) = @_;
+
+ if (open my $fh, '>', $file) {
+ my $contents = do {
+ local $/;
+ <DATA>
+ };
+ $contents =~ s/use 5.XXX/use $]/;
+ print $fh $contents;
+ close $fh;
+
+ return 1;
+ }
+ else {
+ warn "Couldn't write to $file";
+
+ return 0;
+ }
+}
+
=method usage($exitcode)
Prints usage information to the screen. If C<$exitcode> is 0, it will be