class Bismas::CLI
Public Class Methods
defaults()
click to toggle source
Calls superclass method
# File lib/bismas/cli.rb 34 def self.defaults 35 super.merge( 36 config: "#{name.split('::').last.downcase}.yaml", 37 input: '-', 38 output: '-' 39 ) 40 end
Public Instance Methods
execute_options(opts)
click to toggle source
# File lib/bismas/cli.rb 75 def execute_options(opts) 76 opts.option(:execute__FILE_OR_CODE, 'Code to execute for each _record_ before mapping') { |e| 77 (options[:execute] ||= []) << e 78 } 79 80 opts.option(:execute_mapped__FILE_OR_CODE, :E, 'Code to execute for each _record_ after mapping') { |e| 81 (options[:execute_mapped] ||= []) << e 82 } 83 84 opts.separator 85 86 opts.option(:execute_before__FILE_OR_CODE, :B, 'Code to execute before processing records') { |e| 87 (options[:execute_before] ||= []) << e 88 } 89 90 opts.option(:execute_after__FILE_OR_CODE, :A, 'Code to execute after processing records') { |e| 91 (options[:execute_after] ||= []) << e 92 } 93 end
input_options(opts)
click to toggle source
# File lib/bismas/cli.rb 50 def input_options(opts) 51 opts.separator 52 opts.separator 'Input options:' 53 54 opts.option(:input_encoding__ENCODING, :N, "Input encoding [Default: #{DEFAULT_ENCODING}]") 55 56 opts.separator 57 58 opts.option(:input_key__KEY, :K, 'ID key of input file') 59 60 opts.separator 61 62 opts.switch(:strict, :S, 'Turn parse warnings into errors') 63 64 opts.switch(:silent, :T, 'Silence parse warnings') 65 66 opts.separator 67 68 opts.switch(:legacy, :L, 'Use the legacy parser') 69 end
require_gem(*args)
click to toggle source
# File lib/bismas/cli.rb 42 def require_gem(*args) 43 Bismas.require_gem(*args, &method(:abort)) 44 end
type_option(opts, types = self.class::TYPES)
click to toggle source
# File lib/bismas/cli.rb 71 def type_option(opts, types = self.class::TYPES) 72 opts.option(:type__TYPE, "Output file type (#{types.join(', ')}) [Default: #{types.first}]") 73 end
unsupported_type(type, types = self.class::TYPES)
click to toggle source
# File lib/bismas/cli.rb 46 def unsupported_type(type, types = self.class::TYPES) 47 quit "Unsupported type: #{type}. Must be one of: #{types.join(', ')}." 48 end