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