Sha256: 161f7370c5b2546ac2334d5cd7913e97fd1529e7807867c260e7cb6db2bf1988
Contents?: true
Size: 1.98 KB
Versions: 1
Compression:
Stored size: 1.98 KB
Contents
require 'fileutils' command :new do |c| c.syntax = 'helios new path/to/app' c.summary = 'Creates a new Helios project' c.description = <<-EOF The `helios new` command creates a new Helios application with a default directory structure and configuration at the path you specify. EOF # c.example = <<-EOF # helios new #{File.join(Dir.pwd, "app")} # This generates a skeletal Helios installation in #{File.join(Dir.pwd, "app")}. # See the README in the newly created application to get going. # EOF c.option '--skip-gemfile', "Don't create a Gemfile" c.option '-B', '--skip-bundle', "Don't run bundle install" c.option '-G', '--skip-git', "Don't create a git repository" c.option '--edge', "Setup the application with Gemfile pointing to Helios repository" c.option '-f', '--force', "Overwrite files that already exist" c.option '-p', '--pretend', "Run but do not make any changes" c.option '-s', '--skip', "Skip files that already exist" c.action do |args, options| say_error "Missing argument" and abort if args.empty? path = args.first app_name = path.split(/\//).last begin FileUtils.mkdir_p(path) and Dir.chdir(path) Dir.glob(File.join(File.dirname(__FILE__), "../templates/") + "*.erb", File::FNM_DOTMATCH).each do |template| file = File.basename(template, ".erb") erb = ERB.new(File.read(template)) next if file === "Gemfile" and options.skip_gemfile if File.exist?(file) if options.force and not options.skip log "create", file else log "exists", file end end next if options.pretend File.open(file, 'w') do |f| f.puts erb.result binding end end `bundle` unless options.skip_bundle or not File.exist?("Gemfile") `git init` unless options.skip_git rescue => exception say_error exception.message and abort end end end alias_command :create, :new alias_command :generate, :new
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
helios-0.1.1 | ./lib/helios/commands/new.rb |