#!/usr/bin/env ruby $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib') require 'gli' require 'box' require 'feedbook' require 'fileutils' include GLI::App program_desc 'Feedbook is a simple gem and application that notifies about new posts and Atom/RSS updates on your social media sites (like Facebook and Twitter), e-mail or IRC.' flag [:c,:config], default_value: 'feedbook.yml', desc: 'Feedbook configuration file location' desc 'Parses feedbook.yml file for feeds and configuration and listen for changes in RSS/Atom feeds to notify about updates on social media sites' command :start do |c| c.action do |global_options, _, _| Feedbook::Listener.start(global_options[:config]) end end desc 'Creates basic feedbook config file' command :init do |c| c.action do |global_options, _, _| abort 'There is already a feedbook configuration file' if File.exist?(global_options[:config]) File.open(global_options[:config], 'w') { |f| f.write(Box::FILES['feedbook']) } puts "=> Created default feedbook configuration file: #{global_options[:config]}" end end desc 'Outputs feedbook gem version' command :version do |c| c.action do |global_options, _, _| puts "feedbook version: #{Feedbook::VERSION}" end end on_error do |exception| case exception when SystemExit else STDERR.puts "Error: #{exception} (#{exception.class})" STDERR.puts exception.backtrace.join("\n") end false end exit run(ARGV) __END__ @@ feedbook ## Feedbook default config file, modify it! feeds: - url: https://github.com/pinoss.atom variables: default_header: Check out our new post notifications: - type: facebook template: "{{ default_header }} {{ title }} by {{ author }}: {{ url }}" - type: twitter template: "{{ default_header }} on our blog {{ feed_url }}: {{ title }}/{{ url }}" configuration: interval: 5m facebook: token: SECRET_FACEBOOK_TOKEN twitter: consumer_key: SECRET_CONSUMER_KEY consumer_secret: SECRET_TWITTER_CONSUMER_SECRET access_token: SECRET_TWITTER_ACCESS_TOKEN access_token_secret: SECRET_TWITTER_ACCESS_TOKEN_SECRET