class Kontena::Cli::Etcd::ListCommand

Public Instance Methods

execute() click to toggle source
# File lib/kontena/cli/etcd/list_command.rb, line 19
def execute
  validate_key

  response = spin_if(!quiet?, "Retrieving keys from etcd") do
    client.get("etcd/#{current_grid}/#{key}#{'?recursive=true' if recursive?}")
  end

  if response['children']
    children = response['children'].map{|c| c['key'] }
    puts children.join("\n")
  elsif response['value']
    exit_with_error "Not a directory"
  elsif response['error']
    exit_with_error response['error']
  end
end