Class: ServiceTemplate::CLI::Base
- Inherits:
-
Thor
- Object
- Thor
- ServiceTemplate::CLI::Base
- Defined in:
- lib/service_template/cli.rb
Instance Method Summary collapse
- #console(environment = nil) ⇒ Object
- #deploy(environment) ⇒ Object
- #server ⇒ Object
- #version ⇒ Object
Instance Method Details
#console(environment = nil) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/service_template/cli.rb', line 36 def console(environment = nil) ServiceTemplate.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
83 84 85 86 87 88 89 90 91 92 |
# File 'lib/service_template/cli.rb', line 83 def deploy(environment) if [:confirm] || yes?('Are you sure you want to deploy this service?', Thor::Shell::Color::YELLOW) deploy = ServiceTemplate::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 |
#server ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/service_template/cli.rb', line 61 def server puts "ServiceTemplate server starting..." require 'pty' exit = "... ServiceTemplate 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 |
#version ⇒ Object
30 31 32 |
# File 'lib/service_template/cli.rb', line 30 def version say ServiceTemplate::VERSION end |