Class: HmxClient::Command::Config

Inherits:
Base
  • Object
show all
Defined in:
lib/hmx/command/config.rb

Overview

Manage app config vars

Constant Summary

Constants inherited from Base

Base::FILE

Instance Attribute Summary

Attributes inherited from Base

#args, #options

Instance Method Summary collapse

Methods inherited from Base

#hmx, #initialize, #loadConfig!, namespace, #removeConfig, #storeConfig, #writeConfig

Methods included from Helpers

#display, #display_row, #display_tab, #display_table, #error, #getFromUser, #longest

Constructor Details

This class inherits a constructor from HmxClient::Command::Base

Instance Method Details

#addObject

config:add KEY1=VALUE1 …

add one or more config vars



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/hmx/command/config.rb', line 23

def add
  unless args.size > 0 and args.all? { |a| a.include?('=') }
    raise CommandFailed, "Usage: hmx config:add <key>=<value> [<key2>=<value2> ...]"
  end

  args.inject({}) do |vars, arg|
    key, value = arg.split('=', 2)
    storeConfig(key.to_sym,value)
  end

  display_vars(@config, :indent => 2)
end

#indexObject

config

display the config vars for an app

-s, –shell # output config vars in shell format



15
16
17
# File 'lib/hmx/command/config.rb', line 15

def index
  display_vars(@config, :long => true, :shell => false)
end

#removeObject

config:remove KEY1 [KEY2 …]

remove a config var

Raises:



40
41
42
43
44
45
46
47
# File 'lib/hmx/command/config.rb', line 40

def remove
  raise CommandFailed, "Usage: hmx config:remove KEY1 [KEY2 ...]" if args.empty?

  args.each do |key|
	removeConfig(key.to_sym)
    display_vars(@config, :indent => 2)
  end
end