Class: ConfigCommand

Inherits:
Object
  • Object
show all
Includes:
CommandProc
Defined in:
lib/clui_config.rb

Instance Method Summary collapse

Methods included from CommandProc

#help, included

Constructor Details

#initialize(name) ⇒ ConfigCommand

Returns a new instance of ConfigCommand.



7
8
9
# File 'lib/clui_config.rb', line 7

def initialize(name)
  @handler = ConfigHandler.new
end

Instance Method Details

#delete(args) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/clui_config.rb', line 38

def delete(args)
  if (args.length != 1)
    puts "usage: delete <name>"
    error
  end
  @handler.delete(args[0])
end

#get(args) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/clui_config.rb', line 22

def get(args)
  if (args.length != 1)
    puts "usage: get <name>"
    error
  end
  puts @handler.get(args[0])
end

#init(args) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/clui_config.rb', line 11

def init(args)
  if (args.length != 2)
    puts "usage: init <account-num> <token>"
    puts "go to my.edgecast.com --> Settings to find it"
  else
    @handler.set("acct-num", args[0])
    @handler.set("token", args[1])
    @handler.set("rest_base_url", "https://api.edgecast.com/v2/")
  end
end

#set(args) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/clui_config.rb', line 30

def set(args)
  if (args.length != 2)
    puts "usage: set <name> <value>"
    error
  end
  @handler.set(args[0], args[1])
end