]>
jfr.im git - irc/pisg.git/blob - pisg/pisg
6 # pisg - Perl IRC Statistics Generator
8 # Copyright (C) 2001-2005 <Morten Brix Pedersen> - morten@wtf.dk
9 # Copyright (C) 2003-2006 Christoph Berg <cb@df7cb.de>
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 # If the script was executed as ./pisg - then we just remove
30 # everything after the last slash, if it was executed as 'perl pisg'
31 # we assume that we are executing in the current dir.
32 if ($script_dir =~ m/\/[^\
/]*$/) {
33 $script_dir =~ s/\/[^\/]*$//;
38 if (!-t STDOUT
) { # we are not writing to a terminal
39 push @ARGV, "--silent";
42 my $cfg = get_cmdline_options
($script_dir);
43 unshift(@INC, $cfg->{modules_dir
});
46 if ($cfg->{version
}) {
48 undef $cfg->{version
};
57 use_configfile => '1',
58 override_cfg => \$cfg,
59 search_path => \$script_dir,
63 print \$pisg->{cfg}->{version} . "\n";
69 print STDERR
"Could not load pisg! Reason:\n$@\n";
74 sub get_cmdline_options
76 my $script_dir = shift;
79 modules_dir
=> "$script_dir/modules/", # Module search path
85 my ($tmp, $help, $silent, $option, @cfg);
87 my $usage = <<END_USAGE;
88 Usage: pisg [-ch channel] [-l logfile] [-o outputfile] [-ma maintainer]
89 [-f format] [-ne network] [-d logdir] [-mo moduledir] [-s] [-v] [-h]
91 -ch --channel=xxx : Set channel name
92 -cc --cchannels=xxx : Only do this channel from cfg file, give multiple
93 times to do multiple channels
94 -l --logfile=xxx : Log file to parse, give multiple times to use
96 -o --outfile=xxx : Name of HTML file to create
97 -t --tag=xxx : Replace \%t in --outfile by xxx
98 -ma --maintainer=xxx : Channel/statistics maintainer
99 -f --format=xxx : Logfile format [see FORMATS file]
100 -ne --network=xxx : IRC network for the channel
101 -d --dir=xxx : Analyze all files in this dir. Ignores logfile.
102 Give multiple times to use multiple directories.
103 -nf --nfiles=xxx : Analyze the last xxx files if used with --dir
104 -p --prefix=xxx : Analyze only files prefixed by xxx in dir
105 Only works with --dir
106 -cf --cfg opt=value : Specify configuration options, eg. -cf ShowWpl=1
107 -co --configfile=xxx : Configuration file
108 -mo --moduledir=xxx : Directory containing pisg modules
109 -s --silent : Suppress output (except error messages)
110 -v --version : Show version
111 -h --help : Output this message and exit.
115 \$ pisg -ne IRCnet -f xchat -o suid.html -ch \\#channel -l logfile.log
117 All options may also be defined by editing the configuration file and
118 calling pisg without arguments.
121 if (GetOptions
('channel=s' => \
$cfg{channel
},
122 'cchannels=s@' => \
@{ $cfg{cchannels
} },
123 'logfile=s' => \
@{ $cfg{logfile
} },
124 'format=s' => \
$cfg{format
},
125 'network=s' => \
$cfg{network
},
126 'maintainer=s' => \
$cfg{maintainer
},
127 'outfile=s' => \
$cfg{outputfile
},
128 'tag=s' => \
$cfg{outputtag
},
129 'dir=s' => \
@{ $cfg{logdir
} },
130 'nfiles=i' => \
$cfg{nfiles
},
131 'prefix=s' => \
$cfg{logprefix
},
132 'moduledir=s' => \
$cfg{moduledir
},
133 'configfile=s' => \
$cfg{configfile
},
134 'ignorefile=s' => \
$tmp,
135 'aliasfile=s' => \
$tmp,
136 'silent' => \
$silent,
137 'version' => \
$cfg{version
},
145 die("The aliasfile and ignorefile has been obsoleted by the new
146 pisg.cfg, please use that instead [see pisg.cfg]\n");
149 if ($silent) { $cfg{silent
} = 1; }
156 print STDERR
"Warning: Couldn't parse -cfg option\n";
165 main
(); # Run the script