Class: Bcome::RenderIrb

Inherits:
Object show all
Defined in:
lib/render_irb.rb

Instance Method Summary collapse

Instance Method Details

#list_items(parent_collection, items) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/render_irb.rb', line 3

def list_items(parent_collection, items)
  if !items || !items.any?
    print "\nNo resources collections found. Maybe you forgot to add any?".headsup
  else
   print  "\n #{parent_collection}\n\n".colorize(:green) # are available:\n\n".colorize(:green)
   items.each do |item|
      colour = item.highlight? ? :yellow : :green
      print "* #{item.do_describe}\n".colorize(colour)
    end
  end
  print "\n"
end


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/render_irb.rb', line 16

def menu(menu_items, stack_level_instance)
  recipe_menu_items = ::Bcome::Orchestrator::Recipe.as_menu_items(stack_level_instance)
  menu_items +=  recipe_menu_items if recipe_menu_items.any? 

  menu_str = "\n** Commands **\n\n"
  menu_str = "\n\The following commands are available: \n\n"
  menu_items.each do |item|
    command = item[:command]
    description = item[:description]
    usage = item[:usage]

    menu_str += "> #{command}\n"
    menu_str += "- #{description}\n"
    menu_str += "e.g. #{usage}\n" if usage

    menu_str += "\n"
  end
  menu_str += "\n\n"
  print menu_str.menu
end