comparison makeitso/makeitso.py @ 110:613e9c19a98c

add a --list-templates command
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 14 Jan 2011 18:17:25 -0800
parents 32893f67f85d
children 51c9cb49edec
comparison
equal deleted inserted replaced
109:697568ba4a22 110:613e9c19a98c
441 action='store_true', default=False, 441 action='store_true', default=False,
442 help="print the commandline to invoke this script TTW") 442 help="print the commandline to invoke this script TTW")
443 parser.add_option('--variables', dest='variables', 443 parser.add_option('--variables', dest='variables',
444 action='store_true', default=False, 444 action='store_true', default=False,
445 help='print the variables in a template') 445 help='print the variables in a template')
446 entry_points = get_entry_points()
447 if entry_points:
448 parser.add_option('--list-templates', dest='list_templates',
449 action='store_true', default=False,
450 help="list installed MakeItSo! templates")
451
446 452
447 options, args = parser.parse_args(args) 453 options, args = parser.parse_args(args)
454
455 # list the templates
456 if entry_points and options.list_templates:
457 for key in sorted(entry_points.keys()):
458 template_class = entry_points[key]
459 description = getattr(template_class, 'description', '')
460 description = description or getattr(template_class, '__doc__', '')
461 description = description.strip()
462 print key + ': ' + description
463 return
448 464
449 # print the variables for the templates 465 # print the variables for the templates
450 if options.variables: 466 if options.variables:
451 467
452 # makes no sense without a template 468 # makes no sense without a template