Sha256: 22c4c39e51fa3d8e14b22c4437f49a6cc5516be302a8054aedf5288bd0ee0f97
Contents?: true
Size: 1.4 KB
Versions: 25
Compression:
Stored size: 1.4 KB
Contents
require_relative '__base__' module Eucalypt class CLI < Thor using Colorize include Eucalypt::Helpers::Messages option :port, type: :numeric, aliases: '-p', desc: 'Port to serve the application on' option :rerun, type: :boolean, aliases: '-r', desc: 'Rerun (watch for file changes and restart server)' option :quiet, type: :boolean, aliases: '-q', desc: 'Silences rerun (runs less verbosely)' desc "launch [ENV]", "Launches your application".colorize(:grey) def launch(env = ENV['APP_ENV']||'development') directory = File.expand_path('.') if Eucalypt.app? directory unless %w[p production d development t test].include? env Out.error "Invalid Rack environment #{env.colorize(:bold)}" return end cmd = "bundle exec rackup -p #{options[:port]||9292}" if options[:rerun] cmd = "rerun \"#{cmd}\"" cmd.gsub!('rerun', 'rerun -q') if options[:quiet] end env = map_env env puts "Running command: #{cmd.colorize(:bold)}" puts "Rack environment: #{env.colorize(:bold)}" exec "env APP_ENV=#{env} #{cmd}" else Eucalypt::Error.wrong_directory end end no_tasks do def map_env(env) case env when ?p then 'production' when ?d then 'development' when ?t then 'test' else env end end end end end
Version data entries
25 entries across 25 versions & 1 rubygems