summaryrefslogtreecommitdiff
path: root/bin/client
blob: a22692eb0bcbba80dd629d7013757afebdae2e57 (plain)
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
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env perl 
use strict;
use warnings;
use FindBin::libs;
use DeWeave::Storage;
use DeWeave::Crypto;
use DeWeave::Collection;
use Getopt::Long;
use Class::MOP;
use Log::Log4perl;
 
my ($server,$username,$password,$sync_key,$what,$verbose);
 
{
my $p = Getopt::Long::Parser->new(
    config => [qw(
                     no_auto_abbrev
                     no_getopt_compat
                     no_gnu_compat
                     require_order
                     no_ignore_case
             )],
);
die unless $p->getoptions(
    'h|host=s' => \$server,
    'u|user=s' => \$username,
    'p|pass|password=s' => \$password,
    'k|key|sync-key=s' => \$sync_key,
    'v|verbose!' => \$verbose,
);
}
 
Log::Log4perl->easy_init({
    level => ( $verbose ? 'DEBUG' : 'WARN' ),
    utf8 => 1,
    layout => "%c %M %m\n",
});
 
my $storage = DeWeave::Storage->new({
    ($server ? (server_uri => $server) : () ),
    username => $username,
    password => $password,
});
 
my $crypto = DeWeave::Crypto->new({
    storage => $storage,
    sync_key => $sync_key,
});
 
$what=ucfirst(shift);
my $class = "DeWeave::Collection::$what";
Class::MOP::load_class($class);
 
my $foo = $class->fetch($storage,$crypto);
 
if ($what eq 'Bookmarks') {
    print $foo->as_tree('toolbar');
    print $foo->as_tree('menu');
}
else {
    print $_->as_string,"\n" for @{$foo->items};
}