root/lang/perl/XMPP-Bomber/trunk/script/xmpp-bomber @ 13192

Revision 13192, 1.0 kB (checked in by daisuke, 5 years ago)

add a function to create a par file

  • Property svn:executable set to 1
Line 
1#!/usr/local/bin/perl
2use strict;
3use File::Spec;
4use Getopt::Long;
5use XMPP::Bomber;
6
7my @caller = caller();
8main() if (!@caller || $caller[0] eq 'PAR');
9
10sub main
11{
12    my %opts;
13    my @opts = qw(
14        config=s
15        username=s
16        password=s
17        domain=s
18        help!
19    );
20
21    if (! GetOptions(\%opts, @opts)) {
22        exit 1;
23    }
24
25    if ($opts{help}) {
26        require Pod::Usage;
27        Pod::Usage::pod2usage(2);
28    }
29
30    # Read the config, if any
31    my $config = {};
32    my $config_file = $opts{config} ||
33        File::Spec->catfile((getpwuid($>))[7], '.xmppbomberrc');
34    if (-f $config_file) {
35        require Config::Any;
36        my $list = Config::Any->load_files({
37            files => [ $config_file ],
38            use_ext => 1,
39        });
40        $config = $list->[0]->{ $config_file } or die;
41    }
42    $config = { %$config, %opts };
43
44    my $bomber = XMPP::Bomber->new(%$config);
45    $bomber->run;
46}
47
481;
49
50__END__
51
52=head1 NAME
53
54xmpp-bomber - Front End To XMPP::Bomber
55
56=head1 SYNOPSIS
57
58  xmpp-bomber [ --config=config.yaml ]
59
60=cut
Note: See TracBrowser for help on using the browser.