mirror of
https://github.com/pragma-/pbot.git
synced 2025-02-23 17:11:06 +01:00
PBot: refactor the two argument parsing loops into one loop
This commit is contained in:
parent
bd38b53288
commit
85e08eee9e
10
PBot/PBot.pm
10
PBot/PBot.pm
@ -69,21 +69,18 @@ sub initialize {
|
||||
my $plugin_dir = $conf{plugin_dir};
|
||||
my $update_dir = $conf{update_dir};
|
||||
|
||||
# check command-line arguments for directory overrides
|
||||
# process command-line arguments
|
||||
foreach my $arg (@ARGV) {
|
||||
if ($arg =~ m/^-?(?:general\.)?((?:data|module|plugin|update)_dir)=(.*)$/) {
|
||||
# check command-line arguments for directory overrides
|
||||
my $override = $1;
|
||||
my $value = $2;
|
||||
$data_dir = $value if $override eq 'data_dir';
|
||||
$module_dir = $value if $override eq 'module_dir';
|
||||
$plugin_dir = $value if $override eq 'plugin_dir';
|
||||
$update_dir = $value if $override eq 'update_dir';
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
# check command-line arguments for registry overrides
|
||||
foreach my $arg (@ARGV) {
|
||||
next if $arg =~ m/^-?(?:general\.)?(?:config|data|module|plugin|update)_dir=.*$/; # already processed
|
||||
my ($item, $value) = split /=/, $arg, 2;
|
||||
|
||||
if (not defined $item or not defined $value) {
|
||||
@ -100,6 +97,7 @@ sub initialize {
|
||||
$section =~ s/^-//; # remove a leading - to allow arguments like -irc.botnick due to habitual use of -args
|
||||
$self->{overrides}->{"$section.$key"} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
# let modules register signal handlers
|
||||
$self->{atexit} = PBot::Registerable->new(%conf, pbot => $self);
|
||||
|
Loading…
x
Reference in New Issue
Block a user