Class: MyAsk::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/myask/config.rb

Instance Method Summary collapse

Constructor Details

#initialize(c) ⇒ Config

Returns a new instance of Config.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/myask/config.rb', line 4

def initialize(c)
  c.command :save do |c|
    c.desc "Set MyAsk API URL"
    c.flag [:api_host], type: String

    c.desc "Set MyAsk API Key"
    c.flag [:api_key], type: String

    c.desc "Set MyAsk Project"
    c.flag [:project], type: String

    c.action do |global_options, options, args|
      helper = MyAsk::ConfigHelper.new(global_options, options, args)
      response = helper.save_config
      puts response
      response
    end
  end

  c.command :show do |c|
    c.action do |global_options, options, args|
      helper = MyAsk::ConfigHelper.new(global_options, options, args)
      response = helper.get_config
      puts response
      response
    end
  end

  c.default_command :show
  c
end