Class: Locd::CLI::Command::Proxy

Inherits:
Agent
  • Object
show all
Defined in:
lib/locd/cli/command/proxy.rb

Overview

CLI interface using the thor gem.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Agent

agent_type, #ls, #open, #tail, #truncate_logs, #update

Class Method Details

.agent_classObject

Helpers



50
51
52
# File 'lib/locd/cli/command/proxy.rb', line 50

def self.agent_class
  Locd::Agent::Proxy
end

Instance Method Details

#addObject



90
91
92
93
94
95
96
97
98
# File 'lib/locd/cli/command/proxy.rb', line 90

def add
  agent = agent_class.add **option_kwds( groups: :write )
  
  logger.info "`#{ agent.label }` agent created."
  
  agent.reload if options[:load]
  
  respond agent
end

#plistObject



153
154
155
156
157
158
159
160
161
# File 'lib/locd/cli/command/proxy.rb', line 153

def plist
  agent = proxy
  
  if options[:json] || options[:yaml]
    respond agent.plist
  else
    respond agent.path.read
  end
end

#portObject



125
126
127
# File 'lib/locd/cli/command/proxy.rb', line 125

def port
  respond Locd::Proxy.port
end

#restartObject



189
190
191
# File 'lib/locd/cli/command/proxy.rb', line 189

def restart
  proxy.restart **option_kwds( groups: [ :start, :stop ] )
end

#rmObject



146
147
148
# File 'lib/locd/cli/command/proxy.rb', line 146

def rm
  proxy.remove
end

#run_Object



115
116
117
118
119
# File 'lib/locd/cli/command/proxy.rb', line 115

def run_
  Locd::Proxy.serve \
    bind: options[:bind],
    port: options[:port]
end

#startObject



167
168
169
# File 'lib/locd/cli/command/proxy.rb', line 167

def start
  proxy.start **option_kwds( groups: :start )
end

#statusObject



135
136
137
138
139
140
# File 'lib/locd/cli/command/proxy.rb', line 135

def status
  respond \
    label:  proxy.label,
    port:   proxy.port,
    status: proxy.status
end

#stopObject



178
179
180
# File 'lib/locd/cli/command/proxy.rb', line 178

def stop
  proxy.stop **option_kwds( groups: :stop )
end