blob: f4e851e2ce35f0fdbc56ffe4687bf913d8e679fa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#!/usr/bin/env perl
package sb_config;
use strict;
use warnings;
use Config::Tiny;
sub parse_config
{
my @scalar_configs = ('nick', 'username', 'ircname', 'server', 'password');
my @list_configs = ('channels', 'ignore', 'admins');
my $file = $_[0];
my %built_config;
my $config = Config::Tiny->read($file);
# FIXME catch undefined/missing config options
foreach my $option (@scalar_configs) {
$built_config{$option} = $config->{_}->{$option};
}
foreach my $option (@list_configs) {
my $vals = $config->{_}->{$option};
$vals =~ s/^\s+|\s+$//g;
@built_config{$option} = [split /\s*,\s*/, $vals];
}
return %built_config;
}
1;
|