Method: GetText::Tools::XGetText#parse_arguments

Defined in:
lib/gettext/tools/xgettext.rb

#parse_arguments(*options) ⇒ Object

:nodoc:



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
# File 'lib/gettext/tools/xgettext.rb', line 208

def parse_arguments(*options) #:nodoc:
  output = nil

  parser = OptionParser.new
  banner = _("Usage: %s input.rb [-r parser.rb] [-o output.pot]") % $0
  parser.banner = banner
  parser.separator("")
  description = _("Extract translatable strings from given input files.")
  parser.separator(description)
  parser.separator("")
  parser.separator(_("Specific options:"))

  parser.on("-o", "--output=FILE",
            _("write output to specified file")) do |out|
    output = out
  end

  parser.on("--package-name=PACKAGE",
            _("set package name in output")) do |out|
    @package_name = out
  end

  parser.on("--package-version=VERSION",
            _("set package version in output")) do |out|
    @package_version = out
  end

  parser.on("--msgid-bugs-address=EMAIL",
            _("set report address for msgid bugs")) do |out|
    @msgid_bugs_address = out
  end

  parser.on("--copyright-holder=STRING",
            _("set copyright holder in output")) do |out|
    @copyright_holder = out
  end

  parser.on("--output-encoding=ENCODING",
            _("set encoding for output")) do |encoding|
    @output_encoding = encoding
  end

  parser.on("-r", "--require=library",
            _("require the library before executing xgettext")) do |out|
    require out
  end

  parser.on("-c", "--add-comments[=TAG]",
            _("If TAG is specified, place comment blocks starting with TAG and precedding keyword lines in output file"),
            _("If TAG is not specified, place all comment blocks preceing keyword lines in output file"),
            _("(default: %s)") % _("no TAG")) do |tag|
    @parse_options[:comment_tag] = tag
  end

  parser.on("-d", "--debug", _("run in debugging mode")) do
    $DEBUG = true
  end

  parser.on("-h", "--help", _("display this help and exit")) do
    puts(parser.help)
    exit(true)
  end

  parser.on_tail("--version", _("display version information and exit")) do
    puts(GetText::VERSION)
    exit(true)
  end

  parser.parse!(options)

  [options, output]
end