Sha256: 054d1bd5b5d39451e92728d4491257a0a1f5513c00d42bdd16536e35cfe72db5
Contents?: true
Size: 1.39 KB
Versions: 1
Compression:
Stored size: 1.39 KB
Contents
require "optparse" module Feed2Gram Options = Struct.new(:config_path, :cache_path, :limit, :skip_token_refresh, :populate_cache, keyword_init: true) do undef_method :cache_path def cache_path @cache_path || config_path.sub(/\.yml$/, ".cache.yml") end end class ParsesOptions 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 end.parse!(argv) options end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
feed2gram-0.0.2 | lib/feed2gram/parses_options.rb |