From 8af8540972a6bac8e31f24c2e1efd1388e86e0bb Mon Sep 17 00:00:00 2001 From: Andrew Chilton Date: Tue, 1 Jul 2008 15:18:07 +1200 Subject: [PATCH] Do checking of the config file in a nicer way. --- lib/CIL.pm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/CIL.pm b/lib/CIL.pm index e2be890..bd01a88 100644 --- a/lib/CIL.pm +++ b/lib/CIL.pm @@ -162,7 +162,15 @@ sub get_attachments_for { sub read_config_file { my ( $self, $filename ) = @_; - my $cfg = CIL::Utils->parse_cil_file( $filename ); + # since we might not have a '.cil' file yet (in the case where we're calling 'init', + # then we should just return whatever the defaults are + my $cfg; + if ( -f $filename ) { + $cfg = CIL::Utils->parse_cil_file( $filename ); + } + else { + $cfg = $defaults; + } # set some defaults if we don't have any of these foreach my $key ( keys %$defaults ) { -- 2.39.5