Commits

gyulalaszlo committed fcf5174

added cpp:list command to list all the templates available with their respective README-s

Comments (0)

Files changed (3)

     end
   end
 
+
+  desc 'list', 'Get a list of templates and show their README.md files'
+  def list
+    all_templates = find_all_templates
+    puts "Loading templates from: #{options[:templates].join(", ")}"
+    all_templates.each_pair do |name, dir|
+      puts ' ', name, '-' * name.size
+      puts "  Usage: cpp:gen #{name} <file_name> <directory>"
+      readme = get_template_readme(dir)
+      next unless readme
+      readme.lines.each do |l|
+        puts "  #{l}"
+      end
+
+    end
+  end
+
   private
 
   # Get a hash of all the templates by name
   end
 
 
+  def get_template_readme tpl_dir
+    readme_path = File.join( tpl_dir, 'README.md' )
+    if File.exist? readme_path
+      return "\n#{File.read( readme_path )}\n\n"
+    end
+    nil
+  end
+
+
 
   attr_reader :file_name, :struct_name
 

templates/manager.template/README.md

+Manager-type class
+
+These classes are available through a virtual interface defined in the header, 
+do allocation by themselves, and are generally larger.

templates/test_group.template/test_group.cc

 
         void truth()
         {
-            ASSERT_EQ( 1, 1 );
+            expect_eq( 1, 1 );
         }
     };