diff --git a/bin/new_generator b/bin/new_generator new file mode 100755 index 00000000..864509d3 --- /dev/null +++ b/bin/new_generator @@ -0,0 +1,23 @@ +#!/usr/bin/env ruby +require 'thor' + +class NewGenerator < Thor::Group + include Thor::Actions + + argument :name, type: :string + argument :description, type: :string, default: 'A new generator for RoleModel' + + def self.source_root + File.expand_path('lib/generators/templates') + end + + def generate_generator_files + directory 'generator', "lib/generators/rolemodel/#{name}" + end + + def generate_generator_spec + # TODO: stub out spec file in proper location + end +end + +NewGenerator.start diff --git a/lib/generators/templates/generator/%name%_generator.rb.tt b/lib/generators/templates/generator/%name%_generator.rb.tt new file mode 100644 index 00000000..22c393f5 --- /dev/null +++ b/lib/generators/templates/generator/%name%_generator.rb.tt @@ -0,0 +1,9 @@ +module Rolemodel + class <%= name %>Generator < Rails::Generators::Base + source_root File.expand_path('templates', __dir__) + + def generate_stuff + say 'generating stuff', :green + end + end +end diff --git a/lib/generators/templates/generator/README.md.tt b/lib/generators/templates/generator/README.md.tt new file mode 100644 index 00000000..0918ef88 --- /dev/null +++ b/lib/generators/templates/generator/README.md.tt @@ -0,0 +1,11 @@ +# <%= name %> Generator + +<%= description %> + +## Prerequisites + + - ... + +## What you get + + - ... diff --git a/lib/generators/templates/generator/USAGE.tt b/lib/generators/templates/generator/USAGE.tt new file mode 100644 index 00000000..5bd22b38 --- /dev/null +++ b/lib/generators/templates/generator/USAGE.tt @@ -0,0 +1,5 @@ +Description: + <%= description %> + +Example: + rails generate rolemodel:<%= name %>