Module: HTOTConv::CLI
- Defined in:
- lib/htot_conv/cli.rb
Defined Under Namespace
Classes: ScriptOptions
Class Method Summary collapse
Class Method Details
.main(args = ARGV) ⇒ Object
161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/htot_conv/cli.rb', line 161 def main(args=ARGV) script_opts = HTOTConv::CLI.optparse!(args) = script_opts. = script_opts. = script_opts. inio = ((args.length > 0) && (args[0] != "-"))? File.open(args[0], "rb") : $stdin outio = ((args.length > 1) && (args[1] != "-"))? File.open(args[1], "wb") : $stdout HTOTConv.convert(inio, [:from_type], outio, [:to_type], , ) end |
.optparse!(args) ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/htot_conv/cli.rb', line 134 def optparse!(args) script_opts = ScriptOptions.new OptionParser.new do |opts| script_opts.(opts) begin opts.parse!(args.dup) rescue OptionParser::ParseError => ex $stderr << ex. << "\n" exit 1 end end OptionParser.new do |opts| script_opts.(opts, true) begin opts.parse!(args) rescue OptionParser::ParseError => ex $stderr << ex. << "\n" exit 1 end end script_opts.freeze end |