Class: Agentd::ContextCommands
- Inherits:
-
Thor
- Object
- Thor
- Agentd::ContextCommands
show all
- Includes:
- CLIHelpers
- Defined in:
- lib/agentd/cli.rb
Overview
Instance Method Summary
collapse
Methods included from CLIHelpers
#build_agent, #build_client, #format_json, #status_color
Instance Method Details
#delete(key) ⇒ Object
241
242
243
244
|
# File 'lib/agentd/cli.rb', line 241
def delete(key)
build_agent(options).context_delete(key)
say "Deleted #{key}.", :yellow
end
|
#get(key) ⇒ Object
228
229
230
231
|
# File 'lib/agentd/cli.rb', line 228
def get(key)
value = build_agent(options).context_get(key)
value.nil? ? say("(not set)", :yellow) : puts(format_json(value))
end
|
#list ⇒ Object
222
223
224
225
|
# File 'lib/agentd/cli.rb', line 222
def list
keys = build_agent(options).context_list
keys.empty? ? say("No context keys set.", :yellow) : keys.each { |k| say k }
end
|
#set(key, value) ⇒ Object
234
235
236
237
238
|
# File 'lib/agentd/cli.rb', line 234
def set(key, value)
parsed = (JSON.parse(value) rescue value)
build_agent(options).context_set(key, parsed)
say "#{key} = #{value}", :green
end
|