summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-05-30 00:17:04 -0500
committerJesse Luehrs <doy@tozt.net>2013-05-30 00:17:04 -0500
commit30443a17d94ddee3b5343aefeebb46e8b7383bc1 (patch)
treea201fcd35aec2c6d4810ea622472ffccfc5edd26
parentbbba71fb8cd3327e0a8b8405a0a201d49999cfc1 (diff)
downloadreply-30443a17d94ddee3b5343aefeebb46e8b7383bc1.tar.gz
reply-30443a17d94ddee3b5343aefeebb46e8b7383bc1.zip
autoconfigure if no config file is found
-rw-r--r--bin/repl36
1 files changed, 35 insertions, 1 deletions
diff --git a/bin/repl b/bin/repl
index 3528618..9b41333 100644
--- a/bin/repl
+++ b/bin/repl
@@ -5,4 +5,38 @@ use warnings;
use App::REPL;
-App::REPL->new(script => "$ENV{HOME}/.replrc")->run;
+my $cfg = "$ENV{HOME}/.replrc";
+
+my %args = (script => $cfg);
+if (!-e $cfg) {
+ print("$cfg not found. Generating a default...\n");
+ if (open my $fh, '>', $cfg) {
+ print $fh <DATA>;
+ close $fh;
+ }
+ else {
+ warn "Couldn't write to $cfg";
+ %args = ();
+ }
+}
+
+App::REPL->new(%args)->run;
+
+__DATA__
+load_plugin
+ 'Interrupt',
+
+ 'FancyPrompt',
+ 'DataDumper',
+
+ 'Colors',
+ 'ReadLine',
+ 'Hints',
+ 'Packages',
+ 'LexicalPersistence',
+ ;
+
+postlude <<POSTLUDE;
+use strict;
+use warnings;
+POSTLUDE