Class: Feed2Gram::ParsesOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/feed2gram/parses_options.rb

Instance Method Summary collapse

Instance Method Details

#parse(argv) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/feed2gram/parses_options.rb', line 12

def parse(argv)
  options = Options.new(
    config_path: "feed2gram.yml"
  )

  OptionParser.new do |opts|
    opts.banner = "Usage: feed2gram [options]"

    opts.on "--config PATH", "Path of feed2gram YAML configuration (default: feed2gram.yml)" do |path|
      options.config_path = path
    end

    opts.on "--cache-path PATH", "Path of feed2gram's cache file to track processed entries (default: feed2gram.cache.yml)" do |path|
      options.cache_path = path
    end

    opts.on "--limit POST_COUNT", Integer, "Max number of Instagram posts to create on this run (default: unlimited)" do |limit|
      options.limit = limit
    end

    opts.on "--skip-token-refresh", "Don't attempt to exchange the access token for a new long-lived access token" do
      options.skip_token_refresh = true
    end

    opts.on "--populate-cache", "Populate the cache file with any posts found in the feed WITHOUT posting them to Instagram" do
      options.populate_cache = true
    end

    opts.on "-v", "--verbose", "Enable verbose output" do
      options.verbose = true
    end
  end.parse!(argv)

  options
end