summaryrefslogblamecommitdiff
path: root/lifestream.pl
blob: 88ca227a11ed06926386e6fc29f8e0aaeee6ca05 (plain) (tree)
1
2
3
4
5
6
7
8
9

                   
           

                
 
               

                 
 








                                
 





                                                                            

 

                                       
         
                                



                                    

 

                                                             










                                  
#!/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;
    }
}