Module: HaveAPI::CLI::Utils

Included in:
Authentication::Token, Cli
Defined in:
lib/haveapi/cli/utils.rb

Instance Method Summary collapse

Instance Method Details

#param_option(name, p) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/haveapi/cli/utils.rb', line 5

def param_option(name, p)
  ret = '--'
  name = name.to_s.dasherize

  ret += if p[:type] == 'Boolean'
           "[no-]#{name}"

         else
           "#{name} [#{name.underscore.upcase}]"
         end

  ret
end

#read_param(name, p) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/haveapi/cli/utils.rb', line 19

def read_param(name, p)
  prompt = "#{p[:label] || name}: "

  ask(prompt) do |q|
    q.default = nil
    q.echo = !p[:protected]
  end
end