summary refs log tree commit diff
path: root/lifestream.pl
blob: 88ca227a11ed06926386e6fc29f8e0aaeee6ca05 (plain) (blame)
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
#!/usr/bin/env perl

use strict;
use warnings;
use lib ('lib');

use YAML::Syck;
use Lifestream;
use Getopt::Long;

my $options = GetOptions(
    'config=s'  => \my $config,
    'deploy'    => \my $deploy,
    'add'       => \my $add,
    'url=s'     => \my $url,
    'name=s'    => \my $name,
    'start'     => \my $start,
    'profile=s' => \my $profile,
);

my $yaml_conf = LoadFile($config);

my $schema = Lifestream::Schema->connect( @{ $yaml_conf->{connect_info} } );

if ($deploy) {
    $schema->deploy;
}

if ($add) {
    $schema->resultset('Feed')->create(
        {
            feed_url    => $url,
            name        => $name,
            profile_url => $profile,
        }
    );
}

if ($start) {
    my $app = Lifestream->app( config => LoadFile($config) );
    if ( $0 eq __FILE__ ) {
        require Tatsumaki::Server;
        Tatsumaki::Server->new(
            port => 9999,
            host => 0,
        )->run($app);
    }
    else {
        return $app;
    }
}