You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

45 lines
1.3 KiB

require 'fileutils'
module Squib
# Squib's command-line options
module Commands
# Generate a new Squib project into a fresh directory.
#
# Provides conventions for using Git (you are using version control, right??).
# Also provides some basic layout and config files to start from, along with templates for instructions and other notes you don't want to forget.
#
#
# @example
# squib new foo-blasters
# cd foo-blasters
# ruby deck.rb
# git init
# git add .
# git commit -m "Starting my cool new game using Squib!"
#
# @api public
class New
# :nodoc:
# @api private
def process(args)
raise ArgumentError.new('Please specify a path.') if args.empty?
new_project_path = File.expand_path(args.join(' '), Dir.pwd)
template_path = File.expand_path('../builtin/projects/basic', File.dirname(__FILE__))
FileUtils.mkdir_p new_project_path
if !Dir["#{new_project_path}/**/*"].empty?
$stderr.puts "#{new_project_path} exists and is not empty. Doing nothing and quitting."
else
Dir.chdir(new_project_path) do
FileUtils.cp_r template_path + '/.', new_project_path
end
end
puts "Created basic Squib project in #{new_project_path}."
end
end
end
end