Module: Cli

Extended by:
Cli
Included in:
Cli
Defined in:
lib/sqs_cli/cli.rb

Class Method Summary collapse

Class Method Details

.list_options(message, items, opts = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/sqs_cli/cli.rb', line 13

def self.list_options(message, items, opts={})
  items += ["File..."] if opts[:include_file]
  items += ["STDOUT"] if opts[:include_stdout]

  index = Ask.list message, items
  if opts[:include_file] && items[index] == "File..."
    { filename: (Ask.input "Filename", default: "sqs-cli.b64") }
  elsif opts[:include_stdout] && items[index] == "STDOUT"
    { stream: $stdout }
  else
    { selected_item: items[index] }
  end
end

.wait_with_message(message) ⇒ Object



6
7
8
9
10
11
# File 'lib/sqs_cli/cli.rb', line 6

def self.wait_with_message(message)
  print message
  result = yield if block_given?
  print "\r\e[K"
  result
end