Sha256: 358a77fe82318d2b763dd3d8d58c2a00d6f18c89bf280cb44dcb5b2fcf73c446

Contents?: true

Size: 832 Bytes

Versions: 1

Compression:

Stored size: 832 Bytes

Contents

#!/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)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ig_scrape-0.0.3 bin/ig_scrape