diff --git a/bin/auto b/bin/auto index ea514e9..b5b6827 100755 --- a/bin/auto +++ b/bin/auto @@ -14,6 +14,7 @@ use English qw(-no_match_vars); use Sys::Hostname; use IO::Socket; use IO::Select; +use Getopt::Long; use DBI; use Class::Unload; use FindBin qw($Bin); @@ -44,7 +45,7 @@ use Proto::IRC; use Core::IRC; use Core::Cmd; -our $VERSION = 3.0.0; +our $VERSION = 3.000000; local $PROGRAM_NAME = 'auto'; # Check for build files. @@ -97,6 +98,62 @@ API::Std::event_add('on_sigterm'); API::Std::event_add('on_sigint'); API::Std::event_add('on_sighup'); +# Get arguments. +our ($USECONFIG, $DEBUG); +my ($opt_help, $opt_version); +GetOptions( + 'c=s' => \$USECONFIG, + 'config=s' => \$USECONFIG, + 'h' => \$opt_help, + 'help' => \$opt_help, + 'd' => \$DEBUG, + 'debug' => \$DEBUG, + 'v' => \$opt_version, + 'version' => \$opt_version +); + +# If we were passed -h, print help. +if ($opt_help) { + print <new('auto.conf') or err(1, 'Failed to parse configuration file!', 1); +my $configfile = 'auto.conf'; +if ($USECONFIG) { $configfile = $USECONFIG; } +say "* Parsing configuration file $configfile..."; +our $CONF = Parser::Config->new($configfile) or err(1, 'Failed to parse configuration file!', 1); our %SETTINGS = $CONF->parse or err(1, 'Failed to parse configuration file!', 1); say ' Success'; +undef $configfile; +undef $USECONFIG; if (conf_get('die')) { if ((conf_get('die'))[0][0] == 1) { diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 08b653d..9b805a5 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -3,6 +3,8 @@ Auto IRC Bot 3.0: Change Log 3.0 Indev =============================================================================== + * Added various options to bin/auto, including support for multiple config + files. See bin/auto -h for details. * Changed on_nick, on_quit, on_part, and on_kick source hashrefs to include server, removing svr. * Bumped minimum API version to 3.0.0a7. * Fixed the arguments on_whoreply passes.