From 30443a17d94ddee3b5343aefeebb46e8b7383bc1 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 30 May 2013 00:17:04 -0500 Subject: autoconfigure if no config file is found --- bin/repl | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) 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 ; + 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 <