Sha256: 0a9ad610f94d639e4cfe55c08cccfa5617b8460650d3df13a0e3311b7f1346ec

Contents?: true

Size: 992 Bytes

Versions: 2

Compression:

Stored size: 992 Bytes

Contents

# -*- ruby -*-
# frozen_string_literal: true

require 'pathname'
require 'mongrel2/config'

require 'mongrel2/cli' unless defined?( Mongrel2::CLI )
require 'mongrel2/constants'


# Mongrel2 bootstrap command
module Mongrel2::CLI::BootstrapCommand
	extend Mongrel2::CLI::Subcommand


	desc "Generate a basic config-generation script."
	arg :CONFIG_SCRIPT, :optional
	command :bootstrap do |bootstrapcmd|

		bootstrapcmd.action do |globals, options, args|
			scriptpath = Pathname( args.shift || Mongrel2::Constants::DEFAULT_CONFIG_SCRIPT )
			template   = Mongrel2::DATA_DIR + 'config.rb.in'

			# Read the config DSL template
			data = template.read
			data.gsub!( /%% PWD %%/, Dir.pwd )

			# Write it out
			prompt.say( hl.header "Writing a config-generation script to %s" % [scriptpath] )
			scriptpath.open( File::WRONLY|File::EXCL|File::CREAT, 0755, encoding: 'utf-8' ) do |fh|
				fh.print( data )
			end
			prompt.say "Done."
		end

	end


end # module Mongrel2::CLI::BootstrapCommand

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mongrel2-0.55.0 lib/mongrel2/cli/bootstrap.rb
mongrel2-0.54.0 lib/mongrel2/cli/bootstrap.rb