summaryrefslogtreecommitdiff
path: root/lib/highline/menu.rb
diff options
context:
space:
mode:
authorFrederico <fred.rbittencourt@gmail.com>2016-07-11 00:40:45 -0300
committerFrederico <fred.rbittencourt@gmail.com>2016-07-11 00:40:45 -0300
commitd789f437659d8942f272f92b8374c767963db4c4 (patch)
treeba1225990853739981ecfd82970eb802cd3b89a5 /lib/highline/menu.rb
parent855cc18733a9953ea028456b14186c5a29fa70e0 (diff)
downloadhighline-d789f437659d8942f272f92b8374c767963db4c4.tar.gz
show default option for menus
Diffstat (limited to 'lib/highline/menu.rb')
-rw-r--r--lib/highline/menu.rb22
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/highline/menu.rb b/lib/highline/menu.rb
index 8dc9247..02d547a 100644
--- a/lib/highline/menu.rb
+++ b/lib/highline/menu.rb
@@ -516,23 +516,33 @@ class HighLine
case @layout
when :list
%(<%= header ? "#{header}:\n" : '' %>) +
- "<%= list( menu, #{@flow.inspect},
- #{@list_option.inspect} ) %>" +
+ parse_list +
+ show_default_if_any +
"<%= prompt %>"
when :one_line
%(<%= header ? "#{header}: " : '' %>) +
"<%= prompt %>" +
- "(<%= list( menu, #{@flow.inspect},
- #{@list_option.inspect} ) %>)" +
+ "(" + parse_list + ")" +
+ show_default_if_any +
"<%= prompt[/\s*$/] %>"
when :menu_only
- "<%= list( menu, #{@flow.inspect},
- #{@list_option.inspect} ) %><%= prompt %>"
+ parse_list +
+ show_default_if_any +
+ "<%= prompt %>"
else
@layout
end
end
+ def parse_list
+ "<%= list( menu, #{@flow.inspect},
+ #{@list_option.inspect} ) %>"
+ end
+
+ def show_default_if_any
+ return !@default.to_s.empty? ? "(#{@default}) " : ""
+ end
+
#
# This method will update the intelligent responses to account for
# Menu specific differences. Calls the superclass' (Question's)