File: Version.pm

package info (click to toggle)
xmltv 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,396 kB
  • sloc: perl: 37,189; xml: 5,017; sh: 153; makefile: 18
file content (52 lines) | stat: -rw-r--r-- 1,105 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
=head1 NAME

XMLTV::Version - Adds a --version argument to XMLTV grabbers

=head1 DESCRIPTION

Add a --version argument to your program, eg

  use XMLTV::Version '1.2';

If a --version parameter is supplied on the command-line, it will
be caught already by the "use" statement, a message will be printed
to STDOUT and the program will exit.

It is best to put the use XMLTV::Version statement before other module
imports, so that even if they fail --version will still work.

=head1 SEE ALSO

L<XMLTV::Options>

=cut

package XMLTV::Version;

my $opt = '--version';
sub import( $$ ) {
    die "usage: use $_[0] <version-string>" if @_ != 2;
    my $seen = 0;
    foreach (@ARGV) {
	# This doesn't handle abbreviations in the GNU style.
	last if $_ eq '--';
	if ($_ eq $opt) {
	    $seen++ && warn "seen '$opt' twice\n";
	}
    }
    return if not $seen;

    eval {
	require XMLTV;
	print "XMLTV module version $XMLTV::VERSION\n";
    };
    print "could not load XMLTV module, xmltv is not properly installed\n"
      if $@;
    for ($_[1]) {
	print "This program version $_\n";
    }

    exit();
}

1;