Sha256: 9cae015b67d48e494e55c1551f1915d12f4008e0d2431f209a5f833162721ca8
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
#!/usr/bin/env ruby $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib]) require 'twog' require 'optparse' options = {} opts = OptionParser.new do |opts| opts.banner = "Twog is a tool to tweet blog posts" opts.on("--version", "Display current version") do puts "Twog " + Twog.version exit 0 end opts.on("--conf", "Create default conf file") do AUTH_FILE_NAME = "#{ENV['HOME']}/.twog.yaml" AUTH_CONFIG_FILE = <<-EOS rss_feed: 'http://url.com/feed.rss' consumer_key: 'consumer key' consumer_secret: 'consumer secret' access_token: 'access token' access_secret: 'access secret' bitly_username: 'username' bitly_api_key: 'api key' last_blog_post_tweeted: EOS if File.exists?(AUTH_FILE_NAME) puts "#{ENV['HOME']}/.twog.yaml already exists" exit 0 end File.open(AUTH_FILE_NAME, 'w') {|f| f.write(AUTH_CONFIG_FILE) } puts "Default configuration file created at ~/.twog.yaml" exit 0 end end # Read command line options into `options` hash opts.parse! # Get args from the command line if ARGV.size > 1 puts "Invalid options. Run `twog --help` for assistance." exit(1) end raise "please run 'twog --conf' to create the ~/.twog.yaml file" unless File.exists?("#{ENV['HOME']}/.twog.yaml") conf = YAML.load_file("#{ENV['HOME']}/.twog.yaml") Twog.run(conf)
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
twog-0.2.2 | bin/twog |
twog-0.2.1 | bin/twog |