Class: Napa::CLI::Base
- Inherits:
-
Thor
- Object
- Thor
- Napa::CLI::Base
- Includes:
- Thor::Actions
- Defined in:
- lib/napa/cli/base.rb,
lib/napa/cli/base/new.rb,
lib/napa/cli/base/deploy.rb,
lib/napa/cli/base/server.rb,
lib/napa/cli/base/console.rb,
lib/napa/cli/base/version.rb
Instance Method Summary collapse
- #console(environment = nil) ⇒ Object
- #deploy(environment) ⇒ Object
- #new(name, path = nil) ⇒ Object
- #server ⇒ Object
- #version ⇒ Object
Instance Method Details
#console(environment = nil) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/napa/cli/base/console.rb', line 7 def console(environment = nil) Napa.env = environment || 'development' require 'racksh/init' begin require "pry" interpreter = Pry rescue LoadError require "irb" require "irb/completion" interpreter = IRB # IRB uses ARGV and does not expect these arguments. ARGV.delete('console') ARGV.delete(environment) if environment end Rack::Shell.init $0 = "#{$0} console" interpreter.start end |
#deploy(environment) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/napa/cli/base/deploy.rb', line 9 def deploy(environment) if [:confirm] || yes?('Are you sure you want to deploy this service?', Thor::Shell::Color::YELLOW) deploy = Napa::Deploy.new(environment, force: [:force], revision: [:revision]) if deploy.deployable? say(deploy.deploy!, Thor::Shell::Color::GREEN) else say("Deploy Failed:\n#{deploy.errors.join("\n")}", Thor::Shell::Color::RED) end end end |
#new(name, path = nil) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/napa/cli/base/new.rb', line 15 def new(name, path = nil) say 'Generating scaffold...' @name = name @path = path @database_gem = postgres? ? 'pg' : 'mysql2' @database_adapter = postgres? ? 'postgresql' : 'mysql2' @database_encoding = postgres? ? 'unicode' : 'utf8' @database_user = postgres? ? '' : 'root' directory ".", (path || name) say 'Done!', :green end |
#server ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/napa/cli/base/server.rb', line 7 def server puts "Napa server starting..." require 'pty' exit = "... Napa server exited!" begin PTY.spawn('shotgun') do |stdout, stdin, pid| begin Signal.trap('INT') { Process.kill('INT', pid) } stdout.each { |line| puts line } rescue Errno::EIO puts exit end end rescue PTY::ChildExited puts exit end end |