lib/teapot/command/create.rb in teapot-3.0.0 vs lib/teapot/command/create.rb in teapot-3.1.0
- old
+ new
@@ -27,21 +27,18 @@
module Teapot
module Command
class Create < Samovar::Command
self.description = "Create a new teapot package using the specified repository."
- one :project_name, "The name of the new project in title-case, e.g. 'My Project'."
- one :source, "The source repository to use for fetching packages, e.g. https://github.com/kurocha."
- many :packages, "Any additional packages you'd like to include in the project."
+ one :name, "The name of the new project in title-case, e.g. 'My Project'.", required: true
+ one :source, "The source repository to use for fetching packages, e.g. https://github.com/kurocha.", required: true
+ many :packages, "Any packages you'd like to include in the project.", default: ["generate-project"]
- def invoke(parent)
- raise ArgumentError, "project_name is required" unless @project_name
- raise ArgumentError, "source is required" unless @source
-
+ def invoke
logger = parent.logger
- nested = parent['--root', parent.options[:root] || project_name.gsub(/\s+/, '-').downcase]
+ nested = parent['--root', parent.options[:root] || name.gsub(/\s+/, '-').downcase]
root = nested.root
if root.exist?
raise ArgumentError.new("#{root} already exists!")
end
@@ -49,26 +46,26 @@
# Create and set the project root:
root.create
repository = Rugged::Repository.init_at(root.to_s)
- logger.info "Creating project named #{project_name} at path #{root}...".color(:cyan)
- generate_project(root, @project_name, @source, @packages)
+ logger.info "Creating project named #{name} at path #{root}..."
+ generate_project(root, @name, @source, @packages)
# Fetch the initial packages:
- Fetch[].invoke(nested)
+ Fetch[parent: nested].invoke
context = nested.context
selection = context.select
target_names = selection.configuration.targets[:create]
if target_names.any?
# Generate the initial project files:
- Build[*target_names].invoke(nested)
+ Build[*target_names, parent: nested].invoke
# Fetch any additional packages:
- Fetch[].invoke(nested)
+ Fetch[parent: nested].invoke
end
# Stage all files:
index = repository.index
index.add_all
@@ -80,11 +77,11 @@
parents: repository.empty? ? [] : [repository.head.target].compact,
update_ref: 'HEAD'
)
end
- def generate_project(root, project_name, source, packages)
- name = ::Build::Name.new(project_name)
+ def generate_project(root, name, source, packages)
+ name = ::Build::Name.new(name)
# Otherwise the initial commit will try to include teapot/
File.open(root + ".gitignore", "w") do |output|
output.puts "teapot/"
end