bin/twog in twog-0.1.0 vs bin/twog in twog-0.2.0
- old
+ new
@@ -1,9 +1,48 @@
#!/usr/bin/env ruby
-require 'rubygems'
+$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
+
require 'twog'
+require 'optparse'
-raise "please run 'rake gen_config' to create the ~/.twog.yaml file" unless File.exists?("#{ENV['HOME']}/.twog.yaml")
+help = <<HELP
+Twog is a tool to tweet blog posts.
+
+ Configuration is read from your home directory in the file '.twog.yaml'
+
+ SAMPLE cong.yaml:
+ 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:
+
+HELP
+
+options = {}
+opts = OptionParser.new do |opts|
+ opts.banner = help
+
+ opts.on("--version", "Display current version") do
+ puts "Jekyll " + Twog.version
+ exit 0
+ end
+end
+
+# Read command line options into `options` hash
+opts.parse!
+
+# Get args from the command line
+case ARGV.size
+ when > 0
+ puts "Invalid options. Run `twog --help` for assistance."
+ exit(1)
+end
+
+raise "please run 'rake twog:conf_create' to create the ~/.twog.yaml file" unless File.exists?("#{ENV['HOME']}/.twog.yaml")
conf = YAML.load_file("#{ENV['HOME']}/.twog.yaml")
Twog.run(conf)