2016-04-30 23:53:26 +02:00
|
|
|
package MarkovBot::Config;
|
|
|
|
use base qw(Exporter);
|
2016-07-04 21:32:07 +02:00
|
|
|
use 5.010;
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
2016-04-30 23:53:26 +02:00
|
|
|
|
|
|
|
our @EXPORT = qw(config);
|
|
|
|
|
|
|
|
use FindBin qw($Bin);
|
|
|
|
use YAML::Tiny;
|
|
|
|
|
|
|
|
sub config( $ ) {
|
|
|
|
# config(var)
|
|
|
|
# returns config value
|
|
|
|
|
2016-09-05 13:26:10 +02:00
|
|
|
my $file = "$Bin/config.yml";
|
|
|
|
for (0..$#ARGV) {
|
|
|
|
if ($ARGV[$_] eq "-f") {
|
|
|
|
$file = $ARGV[$_+1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-30 23:53:26 +02:00
|
|
|
my $var = shift;
|
|
|
|
|
2016-09-05 13:26:10 +02:00
|
|
|
my $yaml = YAML::Tiny->read( $file );
|
2016-04-30 23:53:26 +02:00
|
|
|
return $yaml->[0]->{$var};
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|