Skip to content

Instantly share code, notes, and snippets.

@kozyty
Created January 19, 2017 06:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kozyty/51d292d7e577bd055290e46c2be17301 to your computer and use it in GitHub Desktop.
Save kozyty/51d292d7e577bd055290e46c2be17301 to your computer and use it in GitHub Desktop.
Create a template with thor
<%= name %>
<%= config[:username] %>
<%= config[:domain] %>
require 'thor'
class Generator < Thor::Group
include Thor::Actions
argument :name
class_option :username, aliases: '-u', required: true
class_option :domain, aliases: '-d'
def self.source_root
File.dirname(__FILE__)
end
def create_lib_file
say "project_name: #{name}", :green
say "username: #{options[:username]}", :green
if options[:domain]
say "domain: #{options[:domain]}", :green
else
say "Please set up domain later.", :red
end
config = {
username: options[:username],
domain: options[:domain]
}
template('templates/projects/app.tt', "projects/#{name}/app.rb.sample", config)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment