changeset 110:613e9c19a98c

add a --list-templates command
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 14 Jan 2011 18:17:25 -0800
parents 697568ba4a22
children bad70fb08b15
files makeitso/makeitso.py
diffstat 1 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/makeitso/makeitso.py	Fri Jan 14 17:55:08 2011 -0800
+++ b/makeitso/makeitso.py	Fri Jan 14 18:17:25 2011 -0800
@@ -443,9 +443,25 @@
     parser.add_option('--variables', dest='variables',
                       action='store_true', default=False,
                       help='print the variables in a template')
+    entry_points = get_entry_points()
+    if entry_points:
+        parser.add_option('--list-templates', dest='list_templates',
+                          action='store_true', default=False,
+                          help="list installed MakeItSo! templates")
+
     
     options, args = parser.parse_args(args)
 
+    # list the templates
+    if entry_points and options.list_templates:
+        for key in sorted(entry_points.keys()):
+            template_class = entry_points[key]
+            description = getattr(template_class, 'description', '')
+            description = description or getattr(template_class, '__doc__', '')
+            description = description.strip()
+            print key + ': ' + description
+        return
+
     # print the variables for the templates
     if options.variables: