diff options
author | Jesse Luehrs <doy@tozt.net> | 2013-05-30 00:17:04 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2013-05-30 00:17:04 -0500 |
commit | 30443a17d94ddee3b5343aefeebb46e8b7383bc1 (patch) | |
tree | a201fcd35aec2c6d4810ea622472ffccfc5edd26 | |
parent | bbba71fb8cd3327e0a8b8405a0a201d49999cfc1 (diff) | |
download | reply-30443a17d94ddee3b5343aefeebb46e8b7383bc1.tar.gz reply-30443a17d94ddee3b5343aefeebb46e8b7383bc1.zip |
autoconfigure if no config file is found
-rw-r--r-- | bin/repl | 36 |
1 files changed, 35 insertions, 1 deletions
@@ -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 |