Sha256: 6b163364273cde46c46c5de2a052a0fc6ca45754eed54e5b67f0cd6592c063bc
Contents?: true
Size: 1.9 KB
Versions: 3
Compression:
Stored size: 1.9 KB
Contents
require "optparse" namespace :card do desc "ingest card data from mod yaml" task eat: :environment do parse_options :eat do add_opt :m, :mod, "only merge cards in given mod" add_opt :e, :env, "environment of yaml source (default is current env)" add_opt :u, :user, "user to credit unless specified (otherwise uses Decko Bot)" flag_opt :v, :verbose, "progress info and error backtraces" end Cardio::Mod::Eat.new(**options).up exit 0 end desc "export card data to mod yaml" task poop: :environment do parse_options :poop do add_opt :n, :name, "export card with name/mark (handles : and ~ prefixes)" flag_opt :i, :items, "also export card items (with -n)" flag_opt :o, :only_items, "also export card items (with -n)", items: :only add_opt :c, :cql, "export cards found by CQL (in JSON format)" add_opt :m, :mod, "output yaml to data/environment.yml file in mod" add_opt :e, :env, "environment to dump to (default is current env)" add_opt :t, :field_tags, "comma-separated list of field tag marks" end result = Cardio::Mod::Poop.new(**options).out exit 0 if result == :success puts "ERROR in card:poop\n #{result}".red exit 1 end desc "reset cache" task reset_cache: :environment do Card::Cache.reset_all end def options @options ||= {} end def flag_opt letter, key, desc, hash=nil hash ||= { key => true } op.on("-#{letter}", "--#{key.to_s.tr '_', '-'}", desc) { options.merge! hash } end def add_opt letter, key, desc op.on "-#{letter}", "--#{key.to_s.tr '_', '-'} #{key.to_s.upcase}", desc do |val| options[key] = val end end def op @op ||= OptionParser.new end def parse_options task op.banner = "Usage: rake card:#{task} -- [options]" yield if block_given? args = op.order!(ARGV) {} # args << "-h" if args.empty? op.parse! args end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
card-1.104.2 | lib/tasks/card.rake |
card-1.104.1 | lib/tasks/card.rake |
card-1.104.0 | lib/tasks/card.rake |