App-SimplenoteSync

 view release on metacpan or  search on metacpan

bin/simplenotesync  view on Meta::CPAN

#!/usr/bin/env perl

# PODNAME: simplenotesync

use v5.10;
use strict;
use warnings;
use App::SimplenoteSync;
use File::BaseDir;
use Getopt::Long qw/:config no_ignore_case bundling/;
use Pod::Usage;
use Config::INI::Reader;
use Log::Dispatch;
use Log::Any::Adapter;
use Try::Tiny;

my $logger;

our $PROGNAME = 'simplenotesync';

my $opt = {action => 'sync'};

sub get_opts {
    my $getopt = GetOptions(
        $opt,                'help|h',
        'man',               'debug|d!',
        'version|v',         'no_server_updates!',
        'no_local_updates!', 'email=s',
        'password=s',        'quiet|q!',
        'edit|e=s',          'editor=s'
    );

    if ($getopt == 0 or defined $opt->{help}) {
        pod2usage;
    }

    if (defined $opt->{version}) {
        printf "%s version %s [using WebService::Simplenote %s]\n", $PROGNAME,
          $App::SimplenoteSync::VERSION, $WebService::Simplenote::VERSION;
        exit;
    }

    if (defined $opt->{man}) {
        pod2usage(-verbose => 2);
    }

    if (defined $opt->{edit}) {
        $opt->{action} = 'edit';
    }

    # is there a path on the command line?
    if (defined $ARGV[0]) {
        $opt->{notes_dir} = $ARGV[0];
    }

    return 1;
}

sub get_logger {

    my $log_level = 'info';
    if ($opt->{debug}) {
        $log_level = 'debug';
    }

    # TODO interactive/background
    $logger = Log::Dispatch->new(
        outputs => [

            [
                'Syslog',
                min_level => $log_level,
                ident     => $PROGNAME,
            ],
        ],



( run in 1.511 second using v1.01-cache-2.11-cpan-39bf76dae61 )