use POE;
use POE qw(Component::IRC Component::IRC::Plugin::Connector Component::IRC Component::IRC::Plugin::CTCP);
use POE::Component::IRC;
-use Getopt::Mixed "nextOption";
+use Getopt::Long qw( :config no_ignore_case );
use FileHandle;
use Data::Dumper;
use POSIX ":sys_wait_h";
######################################################################
# handle command line arguments
######################################################################
-my $args_init_string = "help h d debug D c=s config=s l=s logfile=s";
-Getopt::Mixed::init($args_init_string);
+# defaults
$main::help = 0;
$main::debug = 0;
$main::debug_traffic = 0;
$main::config_file = "";
# parse options
-my ($argv_option, $argv_value, $argv_pretty);
-while (($argv_option, $argv_value, $argv_pretty) = nextOption()) {
- if ($argv_option eq "h" or $argv_option eq "help") {
- $main::help = 1;
- }
- if ($argv_option eq "d" or $argv_option eq "debug") {
- $main::debug = 1;
- }
- if ($argv_option eq "D") {
- $main::debug_traffic = 1;
- }
- if ($argv_option eq "c" or $argv_option eq "config") {
- $main::config_file = $argv_value;
- }
- if ($argv_option eq "l" or $argv_option eq "logfile") {
- $main::logfile = $argv_value;
- }
+my $args_init_string = "help h d debug D c=s config=s l=s logfile=s";
+unless (
+ GetOptions(
+ 'help|h|?' => \$main::help,
+ 'debug|d' => \$main::debug,
+ 'debug-irc|D' => \$main::debug_traffic,
+ 'config|c=s' => \$main::config_file,
+ 'logfile|l=s' => \$main::logfile,
+ )
+) {
+ # There were some errors with parsing command line options - show help.
+ $main::help = 1;
}
-Getopt::Mixed::cleanup();
-
my $shutdown = 0;
if ($main::help == 1) {
- print "\n";
- print " $0 [options]\n";
- print "\n";
- print "The following options are available:\n";
- print " -h --help\t\tThis help\n";
- print " -d --debug\t\tEnable debug messages\n";
- print " -D\t\t\tEnable IRC traffic debugging\n";
- print " -c --config\t\tConfig file (required)\n";
- print " -l --logfile\t\tLogfile\n";
- print "\n";
+ print <<_END_OF_HELP_;
+
+ $0 [options]
+
+The following options are available:
+ -h --help This help
+ -d --debug Enable debug messages
+ -D --debug-irc Enable IRC traffic debugging
+ -c --config Config file (required)
+ -l --logfile Logfile
+
+_END_OF_HELP_
exit(0);
}