Commit | Line | Data |
---|---|---|
5364a3ac | 1 | #!/usr/bin/perl -w |
2 | ||
5364a3ac | 3 | use Getopt::Long; |
639d9800 | 4 | use Anime::ANN; |
5364a3ac | 5 | |
36bbb0ca | 6 | binmode STDOUT, ":utf8"; |
e5f1f6aa | 7 | GetOptions(\%options, "l=s", "b=s", "d") || exit 1; |
5364a3ac | 8 | |
9 | if($options{"l"}) { | |
639d9800 | 10 | @list = Anime::ANN::getlist($options{"l"}); |
5364a3ac | 11 | foreach $name (@list) { |
12 | print "$name\n"; | |
13 | } | |
14 | exit 0; | |
15 | } | |
16 | ||
e5f1f6aa | 17 | $browse = ""; |
639d9800 | 18 | if($options{"b"}) { |
e5f1f6aa FT |
19 | $browse = $options{"b"}; |
20 | } elsif($options{"d"}) { | |
21 | $browse = `basename "\$(pwd)"`; | |
22 | } | |
23 | if($browse) { | |
24 | $id = Anime::ANN::getid $browse; | |
b7ae13c0 | 25 | if(defined($id)) { |
26 | exec "htmlview", Anime::ANN::geturl($id); | |
27 | } else { | |
e5f1f6aa | 28 | printf STDERR "could not find " . $browse . "\n"; |
b7ae13c0 | 29 | exit 1; |
30 | } | |
639d9800 | 31 | } |
32 | ||
33 | if(!defined($ARGV[0])) { | |
34 | printf STDERR "usage: anndata NAME\n"; | |
35 | exit 1; | |
36 | } | |
37 | ||
38 | unless($id = Anime::ANN::getid $ARGV[0]) { | |
5364a3ac | 39 | printf STDERR "could not find $ARGV[0]\n"; |
40 | exit 1; | |
41 | } | |
42 | ||
639d9800 | 43 | $info = Anime::ANN::getseries $id; |
44 | ||
45 | sub refdump | |
46 | { | |
47 | my($ref, $ind); | |
48 | ($ref, $ind) = @_; | |
49 | if(!defined($ind)) { | |
50 | $ind = 0; | |
51 | } | |
52 | ||
53 | if(ref $ref eq "HASH") { | |
54 | for $key (sort keys %{$ref}) { | |
55 | print ((" " x $ind) . "$key: " . (" " x (20 - length $key)) . "(" . $ref->{$key} . ")\n"); | |
56 | refdump($ref->{$key}, $ind + 1) if ref $ref->{$key}; | |
57 | } | |
58 | } elsif(ref $ref eq "ARRAY") { | |
59 | for($i = 0; $i < @{$ref}; $i++) { | |
60 | print ((" " x $ind) . "$i: " . $ref->[$i] . "\n"); | |
61 | refdump($ref->[$i], $ind + 1) if ref $ref->[$i]; | |
62 | } | |
b7ae13c0 | 63 | } elsif(ref $ref eq "SCALAR") { |
64 | print ((" " x $ind) . $$ref . "\n"); | |
639d9800 | 65 | } else { |
66 | print ((" " x $ind) . "Unknown ref: $ref\n"); | |
67 | } | |
68 | } | |
5364a3ac | 69 | |
639d9800 | 70 | refdump $info; |