Class: Jets::Commands::Main

Inherits:
Base show all
Defined in:
lib/jets/commands/main.rb

Instance Method Summary collapse

Methods inherited from Base

autocomplete, banner, dispatch, eager_load!, help_list, inherited, klass_from_namespace, namespace_from_class, namespaced_commands, perform, special_class_map, subclasses

Instance Method Details

#buildObject



11
12
13
# File 'lib/jets/commands/main.rb', line 11

def build
  Build.new(options).run
end

#call(function_name, payload = '') ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/jets/commands/main.rb', line 83

def call(function_name, payload='')
  # Printing to stdout can mangle up the response when piping
  # the value to jq. For example:
  #
  #   `jets call --local .. | jq`
  #
  # By redirecting stderr we can use jq safely.
  #
  $stdout.sync = true
  $stderr.sync = true
  $stdout = $stderr # jets call operation
  Call.new(function_name, payload, options).run
end

#consoleObject



57
58
59
# File 'lib/jets/commands/main.rb', line 57

def console
  Console.run
end

#dbconsoleObject



69
70
71
# File 'lib/jets/commands/main.rb', line 69

def dbconsole
  Dbconsole.start(*args)
end

#deleteObject



28
29
30
# File 'lib/jets/commands/main.rb', line 28

def delete
  Delete.new(options).run
end

#deploy(environment = nil) ⇒ Object

Note the environment is here to trick the Thor parser to allowing an environment parameter. It is not actually set here. It is set earlier in cli.rb: set_jets_env_for_deploy_command!



20
21
22
# File 'lib/jets/commands/main.rb', line 20

def deploy(environment=nil)
  Deploy.new(options).run
end

#generate(generator, *args) ⇒ Object



99
100
101
# File 'lib/jets/commands/main.rb', line 99

def generate(generator, *args)
  Jets::Generator.invoke(generator, *args)
end

#middlewareObject



123
124
125
126
127
128
129
# File 'lib/jets/commands/main.rb', line 123

def middleware
  stack = Jets.application.middlewares
  stack.middlewares.each do |middleware|
    puts "use #{middleware.name}"
  end
  puts "run #{Jets.application.endpoint}"
end

#routesObject



51
52
53
# File 'lib/jets/commands/main.rb', line 51

def routes
  puts Jets::Router.routes_help
end

#runner(code) ⇒ Object



63
64
65
# File 'lib/jets/commands/main.rb', line 63

def runner(code)
  Runner.run(code)
end

#secretObject



117
118
119
# File 'lib/jets/commands/main.rb', line 117

def secret
  puts SecureRandom.hex(64)
end

#serverObject



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/jets/commands/main.rb', line 37

def server
  # shell out to shotgun for automatic reloading
  o = options
  server_command = o[:reload] ? "shotgun" : "rackup"
  command = "bundle exec #{server_command} --port #{o[:port]} --host #{o[:host]}"
  puts "=> #{command}".colorize(:green)
  puts Jets::Booter.message
  Jets::Booter.check_config_ru!
  Jets::RackServer.start(options) unless ENV['JETS_RACK'] == '0' # rack server runs in background by default
  system(command)
end

#statusObject



105
106
107
# File 'lib/jets/commands/main.rb', line 105

def status
  Jets::Cfn::Status.new(options).run
end

#urlObject



111
112
113
# File 'lib/jets/commands/main.rb', line 111

def url
  Jets::Commands::Url.new(options).display
end

#versionObject



133
134
135
# File 'lib/jets/commands/main.rb', line 133

def version
  puts Jets.version
end