diff options
author | Frederico <fred.rbittencourt@gmail.com> | 2016-07-11 00:40:45 -0300 |
---|---|---|
committer | Frederico <fred.rbittencourt@gmail.com> | 2016-07-11 00:40:45 -0300 |
commit | d789f437659d8942f272f92b8374c767963db4c4 (patch) | |
tree | ba1225990853739981ecfd82970eb802cd3b89a5 /lib/highline/menu.rb | |
parent | 855cc18733a9953ea028456b14186c5a29fa70e0 (diff) | |
download | highline-d789f437659d8942f272f92b8374c767963db4c4.tar.gz |
show default option for menus
Diffstat (limited to 'lib/highline/menu.rb')
-rw-r--r-- | lib/highline/menu.rb | 22 |
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) |