comparison babel/messages/frontend.py @ 163:2faa5dc63068

Slightly simplified CLI-frontend class.
author cmlenz
date Thu, 21 Jun 2007 16:12:38 +0000
parents 661cb602781d
children 533baef258bb
comparison
equal deleted inserted replaced
162:661cb602781d 163:2faa5dc63068
409 extraction and PO file generation functionality. 409 extraction and PO file generation functionality.
410 """ 410 """
411 411
412 usage = '%%prog %s [options] %s' 412 usage = '%%prog %s [options] %s'
413 version = '%%prog %s' % VERSION 413 version = '%%prog %s' % VERSION
414 commands = ['compile', 'extract', 'init'] 414 commands = {
415 command_descriptions = {
416 'compile': 'compile a message catalog to a MO file', 415 'compile': 'compile a message catalog to a MO file',
417 'extract': 'extract messages from source files and generate a POT file', 416 'extract': 'extract messages from source files and generate a POT file',
418 'init': 'create new message catalogs from a template' 417 'init': 'create new message catalogs from a template'
419 } 418 }
420 419
440 def _help(self): 439 def _help(self):
441 print self.parser.format_help() 440 print self.parser.format_help()
442 print "commands:" 441 print "commands:"
443 longest = max([len(command) for command in self.commands]) 442 longest = max([len(command) for command in self.commands])
444 format = " %%-%ds %%s" % max(11, longest) 443 format = " %%-%ds %%s" % max(11, longest)
445 self.commands.sort() 444 commands = self.commands.items()
446 for command in self.commands: 445 commands.sort()
447 print format % (command, self.command_descriptions[command]) 446 for name, description in commands:
447 print format % (name, description)
448 448
449 def compile(self, argv): 449 def compile(self, argv):
450 """Subcommand for compiling a message catalog to a MO file. 450 """Subcommand for compiling a message catalog to a MO file.
451 451
452 :param argv: the command arguments 452 :param argv: the command arguments
453 """ 453 """
454 parser = OptionParser(usage=self.usage % ('init',''), 454 parser = OptionParser(usage=self.usage % ('init',''),
455 description=self.command_descriptions['init']) 455 description=self.commands['init'])
456 parser.add_option('--domain', '-D', dest='domain', 456 parser.add_option('--domain', '-D', dest='domain',
457 help="domain of MO and PO files (default '%default')") 457 help="domain of MO and PO files (default '%default')")
458 parser.add_option('--directory', '-d', dest='directory', 458 parser.add_option('--directory', '-d', dest='directory',
459 metavar='DIR', help='base directory of catalog files') 459 metavar='DIR', help='base directory of catalog files')
460 parser.add_option('--input-file', '-i', dest='input_file', 460 parser.add_option('--input-file', '-i', dest='input_file',
517 a POT file. 517 a POT file.
518 518
519 :param argv: the command arguments 519 :param argv: the command arguments
520 """ 520 """
521 parser = OptionParser(usage=self.usage % ('extract', 'dir1 <dir2> ...'), 521 parser = OptionParser(usage=self.usage % ('extract', 'dir1 <dir2> ...'),
522 description=self.command_descriptions['extract']) 522 description=self.commands['extract'])
523 parser.add_option('--charset', dest='charset', 523 parser.add_option('--charset', dest='charset',
524 help='charset to use in the output (default ' 524 help='charset to use in the output (default '
525 '"%default")') 525 '"%default")')
526 parser.add_option('-k', '--keyword', dest='keywords', action='append', 526 parser.add_option('-k', '--keyword', dest='keywords', action='append',
527 help='keywords to look for in addition to the ' 527 help='keywords to look for in addition to the '
635 """Subcommand for creating new message catalogs from a template. 635 """Subcommand for creating new message catalogs from a template.
636 636
637 :param argv: the command arguments 637 :param argv: the command arguments
638 """ 638 """
639 parser = OptionParser(usage=self.usage % ('init',''), 639 parser = OptionParser(usage=self.usage % ('init',''),
640 description=self.command_descriptions['init']) 640 description=self.commands['init'])
641 parser.add_option('--domain', '-D', dest='domain', 641 parser.add_option('--domain', '-D', dest='domain',
642 help="domain of PO file (default '%default')") 642 help="domain of PO file (default '%default')")
643 parser.add_option('--input-file', '-i', dest='input_file', 643 parser.add_option('--input-file', '-i', dest='input_file',
644 metavar='FILE', help='name of the input file') 644 metavar='FILE', help='name of the input file')
645 parser.add_option('--output-dir', '-d', dest='output_dir', 645 parser.add_option('--output-dir', '-d', dest='output_dir',
Copyright (C) 2012-2017 Edgewall Software