Created
January 19, 2017 06:00
-
-
Save kozyty/51d292d7e577bd055290e46c2be17301 to your computer and use it in GitHub Desktop.
Create a template with thor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= name %> | |
<%= config[:username] %> | |
<%= config[:domain] %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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