171eba46bd55110a95ee56a44aab8f507853d745
commit 171eba46bd55110a95ee56a44aab8f507853d745
Author: spesk1 <spesk@pm.me>
Date: Sun Jun 23 19:41:31 2019 +0000

Basic config file misconfig erroring

diff --git a/README.md b/README.md
index 63b7978..a6087d0 100644
--- a/README.md
+++ b/README.md
@@ -16,6 +16,7 @@ DONE:
* Line numbers for file browsing
* Diff highlighting for log
* Show git:// address for cloning (configurable via config file)
+* Support detection of misconfig of config file (pretty basic at this stage)

TODO:
* Get diff stat for top of log index links
@@ -24,7 +25,6 @@ TODO:
* README.md markdown renderer/parser / display in project index
* (Stretch Goal) HTML based syntax highlighting for files
* (Stretch Goal) Accompanying daemon that will auto regen the website
-* Support detection of misconfig of config file

## Framework Plans ##
* gsg -- Perl script to generate the site, uses modules below
diff --git a/lib/Gsg/ConfigParse.pm b/lib/Gsg/ConfigParse.pm
index da4858b..0b619ad 100644
--- a/lib/Gsg/ConfigParse.pm
+++ b/lib/Gsg/ConfigParse.pm
@@ -22,13 +22,12 @@ sub parse_gsg_config($$) {
my $cat_cmd = findBin("cat",$logger);
my @config_lines = split("\n",shellex("$cat_cmd $config_path",$logger));
my %config_hash;
+ my $line_counter = 1;
foreach my $line ( @config_lines ) {
chomp $line;
if ( $line =~ m/^(.*)\ =\ "(.*)"$/ ) {
$config_hash{$1} = $2;
- }
-
- if ( $line =~ m/^(.*)\ =\ \[(.*)\]/ ) {
+ } elsif ( $line =~ m/^(.*)\ =\ \[(.*)\]/ ) {
my @trimmed_vals;
my @vals = split(",",$2);
foreach my $val (@vals) {
@@ -36,7 +35,14 @@ sub parse_gsg_config($$) {
push(@trimmed_vals,trim($1));
}
$config_hash{$1} = \@trimmed_vals;
+ } elsif ( $line =~ m/^\#/ ) {
+ next;
+ } else {
+ $logger->error("Couldn't parse config line $line_counter : $line : exiting");
+ exit 1;
}
+
+ $line_counter++;
}

return %config_hash;