bin/fb_scrape in fb_scrape-0.0.1 vs bin/fb_scrape in fb_scrape-0.0.5

- old
+ new

@@ -4,45 +4,55 @@ require 'thor' require 'json' class FBScrape::CLI < Thor + desc "version", "Get the version of the client running" + def version + puts FBScrape::VERSION + end + desc "id", "Get the page_id for page" option :page_name, :required => true option :token, :required => true def id begin client = FBScrape::Client.new(options[:page_name], options[:token]) - client.init puts client.id rescue ArgumentError => e puts e.message end end desc "posts", "Get all the posts for the page" option :page_id, :required => true option :token, :required => true + option :limit, :required => false def posts begin + limit = options[:limit] || nil client = FBScrape::Client.new(nil, options[:token], options[:page_id]) - client.load + client.load(limit) + posts = client.posts puts JSON.pretty_generate(posts) rescue ArgumentError => e - puts e.message + puts "Error:" + e.message end end desc "comments", "Get all the comments for a post's shortcode" option :id, :required => true option :token, :required => true option :page_id, :required => false def comments begin - # post = FBScrape::Post.load_from_shortcode(options[:shortcode]) - post = FBScrape::Post.load_from_id(options[:id], options:[token]) + + token = options[:token] + id = options[:id] + + post = FBScrape::Post.load_from_id(id, token) post.load_all_comments comments = post.comments puts JSON.pretty_generate(comments) rescue ArgumentError => e @@ -50,6 +60,6 @@ end end end -IGScrape::CLI.start(ARGV) +FBScrape::CLI.start(ARGV)