#!/usr/bin/env ruby require 'ig_scrape' require 'thor' require 'json' class IGScrape::CLI < Thor desc "posts username", "Get all the posts for the username" option :username, :required => true def posts begin client = IGScrape::Client.new(options[:username]) client.load posts = client.posts puts JSON.pretty_generate(posts) rescue ArgumentError => e puts e.message end end desc "comments shortcode", "Get all the comments for a post's shortcode" option :shortcode, :required => true def comments begin post = IGScrape::Post.load_from_shortcode(options[:shortcode]) post.load_comments comments = post.comments puts JSON.pretty_generate(comments) rescue ArgumentError => e puts e.message end end end IGScrape::CLI.start(ARGV)