Skip to content

Commit

Permalink
Add a init command
Browse files Browse the repository at this point in the history
Resolves #129 by adding a generator following the best practices
on the wiki.
  • Loading branch information
hmadison committed Oct 20, 2015
1 parent 8535ee4 commit e7be419
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/itamae.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
require "itamae/config"
require "itamae/ext"

require "itamae/generators"
require "itamae/generators/project"

module Itamae
# Your code goes here...
end

8 changes: 8 additions & 0 deletions lib/itamae/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,13 @@ def docker(*recipe_files)
def version
puts "Itamae v#{Itamae::VERSION}"
end

desc "init NAME", "Create a new project"
def init(name)
generator = Generators::Project.new
generator.destination_root = name
generator.invoke_all
end

end
end
4 changes: 4 additions & 0 deletions lib/itamae/generators.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Itamae
module Generators
end
end
22 changes: 22 additions & 0 deletions lib/itamae/generators/project.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require 'thor'
require 'thor/group'

module Itamae
module Generators
class Project < Thor::Group
include Thor::Actions

def self.source_root
File.dirname(__FILE__) + '/templates/project'
end

def copy_files
directory '.'
end

def bundle
run 'bundle install'
end
end
end
end
4 changes: 4 additions & 0 deletions lib/itamae/generators/templates/project/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source 'https://rubygems.org'

gem 'itamae'
# gem 'serverspec'
Empty file.
Empty file.

0 comments on commit e7be419

Please sign in to comment.