tty-prompt 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/CHANGELOG.md +37 -1
 - data/README.md +372 -215
 - data/lib/tty-prompt.rb +1 -2
 - data/lib/tty/prompt.rb +145 -142
 - data/lib/tty/prompt/answers_collector.rb +2 -2
 - data/lib/tty/prompt/block_paginator.rb +1 -1
 - data/lib/tty/prompt/choice.rb +1 -1
 - data/lib/tty/prompt/choices.rb +28 -11
 - data/lib/tty/prompt/confirm_question.rb +23 -12
 - data/lib/tty/prompt/const.rb +17 -0
 - data/lib/tty/prompt/converter_dsl.rb +6 -7
 - data/lib/tty/prompt/converter_registry.rb +31 -26
 - data/lib/tty/prompt/converters.rb +139 -32
 - data/lib/tty/prompt/enum_list.rb +27 -19
 - data/lib/tty/prompt/errors.rb +31 -0
 - data/lib/tty/prompt/evaluator.rb +1 -1
 - data/lib/tty/prompt/expander.rb +20 -12
 - data/lib/tty/prompt/keypress.rb +3 -3
 - data/lib/tty/prompt/list.rb +57 -25
 - data/lib/tty/prompt/mask_question.rb +2 -2
 - data/lib/tty/prompt/multi_list.rb +71 -27
 - data/lib/tty/prompt/multiline.rb +6 -5
 - data/lib/tty/prompt/paginator.rb +1 -1
 - data/lib/tty/prompt/question.rb +56 -31
 - data/lib/tty/prompt/question/checks.rb +18 -0
 - data/lib/tty/prompt/selected_choices.rb +76 -0
 - data/lib/tty/prompt/slider.rb +67 -8
 - data/lib/tty/prompt/statement.rb +3 -3
 - data/lib/tty/prompt/suggestion.rb +5 -5
 - data/lib/tty/prompt/symbols.rb +58 -58
 - data/lib/tty/prompt/test.rb +36 -0
 - data/lib/tty/prompt/utils.rb +1 -3
 - data/lib/tty/prompt/version.rb +1 -1
 - metadata +12 -24
 - data/lib/tty/prompt/messages.rb +0 -49
 - data/lib/tty/test_prompt.rb +0 -20
 
    
        data/lib/tty/prompt/slider.rb
    CHANGED
    
    | 
         @@ -7,9 +7,9 @@ module TTY 
     | 
|
| 
       7 
7 
     | 
    
         
             
                #
         
     | 
| 
       8 
8 
     | 
    
         
             
                # @api public
         
     | 
| 
       9 
9 
     | 
    
         
             
                class Slider
         
     | 
| 
       10 
     | 
    
         
            -
                  HELP =  
     | 
| 
      
 10 
     | 
    
         
            +
                  HELP = "(Use %s arrow keys, press Enter to select)"
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
                  FORMAT =  
     | 
| 
      
 12 
     | 
    
         
            +
                  FORMAT = ":slider %d"
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
                  # Initailize a Slider
         
     | 
| 
       15 
15 
     | 
    
         
             
                  #
         
     | 
| 
         @@ -33,6 +33,9 @@ module TTY 
     | 
|
| 
       33 
33 
     | 
    
         
             
                    @active_color = options.fetch(:active_color) { @prompt.active_color }
         
     | 
| 
       34 
34 
     | 
    
         
             
                    @help_color   = options.fetch(:help_color) { @prompt.help_color }
         
     | 
| 
       35 
35 
     | 
    
         
             
                    @format       = options.fetch(:format) { FORMAT }
         
     | 
| 
      
 36 
     | 
    
         
            +
                    @quiet        = options.fetch(:quiet) { @prompt.quiet }
         
     | 
| 
      
 37 
     | 
    
         
            +
                    @help         = options[:help]
         
     | 
| 
      
 38 
     | 
    
         
            +
                    @show_help    = options.fetch(:show_help) { :start }
         
     | 
| 
       36 
39 
     | 
    
         
             
                    @symbols      = @prompt.symbols.merge(options.fetch(:symbols, {}))
         
     | 
| 
       37 
40 
     | 
    
         
             
                    @first_render = true
         
     | 
| 
       38 
41 
     | 
    
         
             
                    @done         = false
         
     | 
| 
         @@ -46,6 +49,7 @@ module TTY 
     | 
|
| 
       46 
49 
     | 
    
         
             
                  # @api public
         
     | 
| 
       47 
50 
     | 
    
         
             
                  def symbols(new_symbols = (not_set = true))
         
     | 
| 
       48 
51 
     | 
    
         
             
                    return @symbols if not_set
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
       49 
53 
     | 
    
         
             
                    @symbols.merge!(new_symbols)
         
     | 
| 
       50 
54 
     | 
    
         
             
                  end
         
     | 
| 
       51 
55 
     | 
    
         | 
| 
         @@ -62,11 +66,39 @@ module TTY 
     | 
|
| 
       62 
66 
     | 
    
         
             
                    end
         
     | 
| 
       63 
67 
     | 
    
         
             
                  end
         
     | 
| 
       64 
68 
     | 
    
         | 
| 
      
 69 
     | 
    
         
            +
                  # Default help text
         
     | 
| 
      
 70 
     | 
    
         
            +
                  #
         
     | 
| 
      
 71 
     | 
    
         
            +
                  # @api public
         
     | 
| 
      
 72 
     | 
    
         
            +
                  def default_help
         
     | 
| 
      
 73 
     | 
    
         
            +
                    arrows = @symbols[:arrow_left] + "/" + @symbols[:arrow_right]
         
     | 
| 
      
 74 
     | 
    
         
            +
                    sprintf(HELP, arrows)
         
     | 
| 
      
 75 
     | 
    
         
            +
                  end
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
                  # Set help text
         
     | 
| 
      
 78 
     | 
    
         
            +
                  #
         
     | 
| 
      
 79 
     | 
    
         
            +
                  # @param [String] text
         
     | 
| 
      
 80 
     | 
    
         
            +
                  #
         
     | 
| 
      
 81 
     | 
    
         
            +
                  # @api private
         
     | 
| 
      
 82 
     | 
    
         
            +
                  def help(text = (not_set = true))
         
     | 
| 
      
 83 
     | 
    
         
            +
                    return @help if !@help.nil? && not_set
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
                    @help = (@help.nil? && not_set) ? default_help : text
         
     | 
| 
      
 86 
     | 
    
         
            +
                  end
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
                  # Change when help is displayed
         
     | 
| 
      
 89 
     | 
    
         
            +
                  #
         
     | 
| 
      
 90 
     | 
    
         
            +
                  # @api public
         
     | 
| 
      
 91 
     | 
    
         
            +
                  def show_help(value = (not_set = true))
         
     | 
| 
      
 92 
     | 
    
         
            +
                    return @show_ehlp if not_set
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
                    @show_help = value
         
     | 
| 
      
 95 
     | 
    
         
            +
                  end
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
       65 
97 
     | 
    
         
             
                  # Range of numbers to render
         
     | 
| 
       66 
98 
     | 
    
         
             
                  #
         
     | 
| 
       67 
99 
     | 
    
         
             
                  # @return [Array[Integer]]
         
     | 
| 
       68 
100 
     | 
    
         
             
                  #
         
     | 
| 
       69 
     | 
    
         
            -
                  # @ 
     | 
| 
      
 101 
     | 
    
         
            +
                  # @api private
         
     | 
| 
       70 
102 
     | 
    
         
             
                  def range
         
     | 
| 
       71 
103 
     | 
    
         
             
                    (@min..@max).step(@step).to_a
         
     | 
| 
       72 
104 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -95,6 +127,13 @@ module TTY 
     | 
|
| 
       95 
127 
     | 
    
         
             
                    @format = value
         
     | 
| 
       96 
128 
     | 
    
         
             
                  end
         
     | 
| 
       97 
129 
     | 
    
         | 
| 
      
 130 
     | 
    
         
            +
                  # Set quiet mode.
         
     | 
| 
      
 131 
     | 
    
         
            +
                  #
         
     | 
| 
      
 132 
     | 
    
         
            +
                  # @api public
         
     | 
| 
      
 133 
     | 
    
         
            +
                  def quiet(value)
         
     | 
| 
      
 134 
     | 
    
         
            +
                    @quiet = value
         
     | 
| 
      
 135 
     | 
    
         
            +
                  end
         
     | 
| 
      
 136 
     | 
    
         
            +
             
     | 
| 
       98 
137 
     | 
    
         
             
                  # Call the slider by passing question
         
     | 
| 
       99 
138 
     | 
    
         
             
                  #
         
     | 
| 
       100 
139 
     | 
    
         
             
                  # @param [String] question
         
     | 
| 
         @@ -128,6 +167,20 @@ module TTY 
     | 
|
| 
       128 
167 
     | 
    
         | 
| 
       129 
168 
     | 
    
         
             
                  private
         
     | 
| 
       130 
169 
     | 
    
         | 
| 
      
 170 
     | 
    
         
            +
                  # Check if help is shown only on start
         
     | 
| 
      
 171 
     | 
    
         
            +
                  #
         
     | 
| 
      
 172 
     | 
    
         
            +
                  # @api private
         
     | 
| 
      
 173 
     | 
    
         
            +
                  def help_start?
         
     | 
| 
      
 174 
     | 
    
         
            +
                    @show_help =~ /start/i
         
     | 
| 
      
 175 
     | 
    
         
            +
                  end
         
     | 
| 
      
 176 
     | 
    
         
            +
             
     | 
| 
      
 177 
     | 
    
         
            +
                  # Check if help is always displayed
         
     | 
| 
      
 178 
     | 
    
         
            +
                  #
         
     | 
| 
      
 179 
     | 
    
         
            +
                  # @api private
         
     | 
| 
      
 180 
     | 
    
         
            +
                  def help_always?
         
     | 
| 
      
 181 
     | 
    
         
            +
                    @show_help =~ /always/i
         
     | 
| 
      
 182 
     | 
    
         
            +
                  end
         
     | 
| 
      
 183 
     | 
    
         
            +
             
     | 
| 
       131 
184 
     | 
    
         
             
                  # Render an interactive range slider.
         
     | 
| 
       132 
185 
     | 
    
         
             
                  #
         
     | 
| 
       133 
186 
     | 
    
         
             
                  # @api private
         
     | 
| 
         @@ -139,7 +192,7 @@ module TTY 
     | 
|
| 
       139 
192 
     | 
    
         
             
                      @prompt.read_keypress
         
     | 
| 
       140 
193 
     | 
    
         
             
                      refresh(question.lines.count)
         
     | 
| 
       141 
194 
     | 
    
         
             
                    end
         
     | 
| 
       142 
     | 
    
         
            -
                    @prompt.print(render_question)
         
     | 
| 
      
 195 
     | 
    
         
            +
                    @prompt.print(render_question) unless @quiet
         
     | 
| 
       143 
196 
     | 
    
         
             
                    answer
         
     | 
| 
       144 
197 
     | 
    
         
             
                  ensure
         
     | 
| 
       145 
198 
     | 
    
         
             
                    @prompt.print(@prompt.show)
         
     | 
| 
         @@ -175,8 +228,9 @@ module TTY 
     | 
|
| 
       175 
228 
     | 
    
         
             
                    else
         
     | 
| 
       176 
229 
     | 
    
         
             
                      header << render_slider
         
     | 
| 
       177 
230 
     | 
    
         
             
                    end
         
     | 
| 
       178 
     | 
    
         
            -
                    if @first_render
         
     | 
| 
       179 
     | 
    
         
            -
             
     | 
| 
      
 231 
     | 
    
         
            +
                    if @first_render && (help_start? || help_always?) ||
         
     | 
| 
      
 232 
     | 
    
         
            +
                        (help_always? && !@done)
         
     | 
| 
      
 233 
     | 
    
         
            +
                      header << "\n" + @prompt.decorate(help, @help_color)
         
     | 
| 
       180 
234 
     | 
    
         
             
                      @first_render = false
         
     | 
| 
       181 
235 
     | 
    
         
             
                    end
         
     | 
| 
       182 
236 
     | 
    
         
             
                    header.join
         
     | 
| 
         @@ -191,8 +245,13 @@ module TTY 
     | 
|
| 
       191 
245 
     | 
    
         
             
                    slider = (@symbols[:line] * @active) +
         
     | 
| 
       192 
246 
     | 
    
         
             
                             @prompt.decorate(@symbols[:bullet], @active_color) +
         
     | 
| 
       193 
247 
     | 
    
         
             
                             (@symbols[:line] * (range.size - @active - 1))
         
     | 
| 
       194 
     | 
    
         
            -
                    value =  
     | 
| 
       195 
     | 
    
         
            -
                    @format 
     | 
| 
      
 248 
     | 
    
         
            +
                    value = range[@active]
         
     | 
| 
      
 249 
     | 
    
         
            +
                    case @format
         
     | 
| 
      
 250 
     | 
    
         
            +
                    when Proc
         
     | 
| 
      
 251 
     | 
    
         
            +
                      @format.call(slider, value)
         
     | 
| 
      
 252 
     | 
    
         
            +
                    else
         
     | 
| 
      
 253 
     | 
    
         
            +
                      @format.gsub(":slider", slider) % [value]
         
     | 
| 
      
 254 
     | 
    
         
            +
                    end
         
     | 
| 
       196 
255 
     | 
    
         
             
                  end
         
     | 
| 
       197 
256 
     | 
    
         
             
                end # Slider
         
     | 
| 
       198 
257 
     | 
    
         
             
              end # Prompt
         
     | 
    
        data/lib/tty/prompt/statement.rb
    CHANGED
    
    | 
         @@ -28,10 +28,10 @@ module TTY 
     | 
|
| 
       28 
28 
     | 
    
         
             
                  #   change the message display to color
         
     | 
| 
       29 
29 
     | 
    
         
             
                  #
         
     | 
| 
       30 
30 
     | 
    
         
             
                  # @api public
         
     | 
| 
       31 
     | 
    
         
            -
                  def initialize(prompt,  
     | 
| 
      
 31 
     | 
    
         
            +
                  def initialize(prompt, newline: true, color: false)
         
     | 
| 
       32 
32 
     | 
    
         
             
                    @prompt  = prompt
         
     | 
| 
       33 
     | 
    
         
            -
                    @newline =  
     | 
| 
       34 
     | 
    
         
            -
                    @color   =  
     | 
| 
      
 33 
     | 
    
         
            +
                    @newline = newline
         
     | 
| 
      
 34 
     | 
    
         
            +
                    @color   = color
         
     | 
| 
       35 
35 
     | 
    
         
             
                  end
         
     | 
| 
       36 
36 
     | 
    
         | 
| 
       37 
37 
     | 
    
         
             
                  # Output the message to the prompt
         
     | 
| 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            require_relative  
     | 
| 
      
 3 
     | 
    
         
            +
            require_relative "distance"
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            module TTY
         
     | 
| 
       6 
6 
     | 
    
         
             
              # A class responsible for terminal prompt interactions.
         
     | 
| 
         @@ -11,9 +11,9 @@ module TTY 
     | 
|
| 
       11 
11 
     | 
    
         
             
                class Suggestion
         
     | 
| 
       12 
12 
     | 
    
         
             
                  DEFAULT_INDENT = 8
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
                  SINGLE_TEXT    =  
     | 
| 
      
 14 
     | 
    
         
            +
                  SINGLE_TEXT    = "Did you mean this?"
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
       16 
     | 
    
         
            -
                  PLURAL_TEXT    =  
     | 
| 
      
 16 
     | 
    
         
            +
                  PLURAL_TEXT    = "Did you mean one of these?"
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
18 
     | 
    
         
             
                  # Number of spaces
         
     | 
| 
       19 
19 
     | 
    
         
             
                  #
         
     | 
| 
         @@ -97,14 +97,14 @@ module TTY 
     | 
|
| 
       97 
97 
     | 
    
         | 
| 
       98 
98 
     | 
    
         
             
                  # @api private
         
     | 
| 
       99 
99 
     | 
    
         
             
                  def build_single_suggestion
         
     | 
| 
       100 
     | 
    
         
            -
                    single_text + "\n" + ( 
     | 
| 
      
 100 
     | 
    
         
            +
                    single_text + "\n" + (" " * indent) + @suggestions.first
         
     | 
| 
       101 
101 
     | 
    
         
             
                  end
         
     | 
| 
       102 
102 
     | 
    
         | 
| 
       103 
103 
     | 
    
         
             
                  # @api private
         
     | 
| 
       104 
104 
     | 
    
         
             
                  def build_multiple_suggestions
         
     | 
| 
       105 
105 
     | 
    
         
             
                    plural_text + "\n" +
         
     | 
| 
       106 
106 
     | 
    
         
             
                    @suggestions.map do |sugest|
         
     | 
| 
       107 
     | 
    
         
            -
                       
     | 
| 
      
 107 
     | 
    
         
            +
                      " " * indent + sugest
         
     | 
| 
       108 
108 
     | 
    
         
             
                    end.join("\n")
         
     | 
| 
       109 
109 
     | 
    
         
             
                  end
         
     | 
| 
       110 
110 
     | 
    
         
             
                end # Suggestion
         
     | 
    
        data/lib/tty/prompt/symbols.rb
    CHANGED
    
    | 
         @@ -7,67 +7,67 @@ module TTY 
     | 
|
| 
       7 
7 
     | 
    
         
             
                # @api public
         
     | 
| 
       8 
8 
     | 
    
         
             
                module Symbols
         
     | 
| 
       9 
9 
     | 
    
         
             
                  KEYS = {
         
     | 
| 
       10 
     | 
    
         
            -
                    tick:  
     | 
| 
       11 
     | 
    
         
            -
                    cross:  
     | 
| 
       12 
     | 
    
         
            -
                    star:  
     | 
| 
       13 
     | 
    
         
            -
                    square:  
     | 
| 
       14 
     | 
    
         
            -
                    square_empty:  
     | 
| 
       15 
     | 
    
         
            -
                    dot:  
     | 
| 
       16 
     | 
    
         
            -
                    bullet:  
     | 
| 
       17 
     | 
    
         
            -
                    bullet_empty:  
     | 
| 
       18 
     | 
    
         
            -
                    marker:  
     | 
| 
       19 
     | 
    
         
            -
                    line:  
     | 
| 
       20 
     | 
    
         
            -
                    pipe:  
     | 
| 
       21 
     | 
    
         
            -
                    ellipsis:  
     | 
| 
       22 
     | 
    
         
            -
                    radio_on:  
     | 
| 
       23 
     | 
    
         
            -
                    radio_off:  
     | 
| 
       24 
     | 
    
         
            -
                    checkbox_on:  
     | 
| 
       25 
     | 
    
         
            -
                    checkbox_off:  
     | 
| 
       26 
     | 
    
         
            -
                    circle:  
     | 
| 
       27 
     | 
    
         
            -
                    circle_on:  
     | 
| 
       28 
     | 
    
         
            -
                    circle_off:  
     | 
| 
       29 
     | 
    
         
            -
                    arrow_up:  
     | 
| 
       30 
     | 
    
         
            -
                    arrow_down:  
     | 
| 
       31 
     | 
    
         
            -
                    arrow_up_down:  
     | 
| 
       32 
     | 
    
         
            -
                    arrow_left:  
     | 
| 
       33 
     | 
    
         
            -
                    arrow_right:  
     | 
| 
       34 
     | 
    
         
            -
                    arrow_left_right:  
     | 
| 
       35 
     | 
    
         
            -
                    heart:  
     | 
| 
       36 
     | 
    
         
            -
                    diamond:  
     | 
| 
       37 
     | 
    
         
            -
                    club:  
     | 
| 
       38 
     | 
    
         
            -
                    spade:  
     | 
| 
      
 10 
     | 
    
         
            +
                    tick: "✓",
         
     | 
| 
      
 11 
     | 
    
         
            +
                    cross: "✘",
         
     | 
| 
      
 12 
     | 
    
         
            +
                    star: "★",
         
     | 
| 
      
 13 
     | 
    
         
            +
                    square: "◼",
         
     | 
| 
      
 14 
     | 
    
         
            +
                    square_empty: "◻",
         
     | 
| 
      
 15 
     | 
    
         
            +
                    dot: "•",
         
     | 
| 
      
 16 
     | 
    
         
            +
                    bullet: "●",
         
     | 
| 
      
 17 
     | 
    
         
            +
                    bullet_empty: "○",
         
     | 
| 
      
 18 
     | 
    
         
            +
                    marker: "‣",
         
     | 
| 
      
 19 
     | 
    
         
            +
                    line: "─",
         
     | 
| 
      
 20 
     | 
    
         
            +
                    pipe: "|",
         
     | 
| 
      
 21 
     | 
    
         
            +
                    ellipsis: "…",
         
     | 
| 
      
 22 
     | 
    
         
            +
                    radio_on: "⬢",
         
     | 
| 
      
 23 
     | 
    
         
            +
                    radio_off: "⬡",
         
     | 
| 
      
 24 
     | 
    
         
            +
                    checkbox_on: "☒",
         
     | 
| 
      
 25 
     | 
    
         
            +
                    checkbox_off: "☐",
         
     | 
| 
      
 26 
     | 
    
         
            +
                    circle: "◯",
         
     | 
| 
      
 27 
     | 
    
         
            +
                    circle_on: "ⓧ",
         
     | 
| 
      
 28 
     | 
    
         
            +
                    circle_off: "Ⓘ",
         
     | 
| 
      
 29 
     | 
    
         
            +
                    arrow_up: "↑",
         
     | 
| 
      
 30 
     | 
    
         
            +
                    arrow_down: "↓",
         
     | 
| 
      
 31 
     | 
    
         
            +
                    arrow_up_down: "↕",
         
     | 
| 
      
 32 
     | 
    
         
            +
                    arrow_left: "←",
         
     | 
| 
      
 33 
     | 
    
         
            +
                    arrow_right: "→",
         
     | 
| 
      
 34 
     | 
    
         
            +
                    arrow_left_right: "↔",
         
     | 
| 
      
 35 
     | 
    
         
            +
                    heart: "♥",
         
     | 
| 
      
 36 
     | 
    
         
            +
                    diamond: "♦",
         
     | 
| 
      
 37 
     | 
    
         
            +
                    club: "♣",
         
     | 
| 
      
 38 
     | 
    
         
            +
                    spade: "♠"
         
     | 
| 
       39 
39 
     | 
    
         
             
                  }.freeze
         
     | 
| 
       40 
40 
     | 
    
         | 
| 
       41 
41 
     | 
    
         
             
                  WIN_KEYS = {
         
     | 
| 
       42 
     | 
    
         
            -
                    tick:  
     | 
| 
       43 
     | 
    
         
            -
                    cross:  
     | 
| 
       44 
     | 
    
         
            -
                    star:  
     | 
| 
       45 
     | 
    
         
            -
                    square:  
     | 
| 
       46 
     | 
    
         
            -
                    square_empty:  
     | 
| 
       47 
     | 
    
         
            -
                    dot:  
     | 
| 
       48 
     | 
    
         
            -
                    bullet:  
     | 
| 
       49 
     | 
    
         
            -
                    bullet_empty:  
     | 
| 
       50 
     | 
    
         
            -
                    marker:  
     | 
| 
       51 
     | 
    
         
            -
                    line:  
     | 
| 
       52 
     | 
    
         
            -
                    pipe:  
     | 
| 
       53 
     | 
    
         
            -
                    ellipsis:  
     | 
| 
       54 
     | 
    
         
            -
                    radio_on:  
     | 
| 
       55 
     | 
    
         
            -
                    radio_off:  
     | 
| 
       56 
     | 
    
         
            -
                    checkbox_on:  
     | 
| 
       57 
     | 
    
         
            -
                    checkbox_off:  
     | 
| 
       58 
     | 
    
         
            -
                    circle:  
     | 
| 
       59 
     | 
    
         
            -
                    circle_on:  
     | 
| 
       60 
     | 
    
         
            -
                    circle_off:  
     | 
| 
       61 
     | 
    
         
            -
                    arrow_up:  
     | 
| 
       62 
     | 
    
         
            -
                    arrow_down:  
     | 
| 
       63 
     | 
    
         
            -
                    arrow_up_down:  
     | 
| 
       64 
     | 
    
         
            -
                    arrow_left:  
     | 
| 
       65 
     | 
    
         
            -
                    arrow_right:  
     | 
| 
       66 
     | 
    
         
            -
                    arrow_left_right:  
     | 
| 
       67 
     | 
    
         
            -
                    heart:  
     | 
| 
       68 
     | 
    
         
            -
                    diamond:  
     | 
| 
       69 
     | 
    
         
            -
                    club:  
     | 
| 
       70 
     | 
    
         
            -
                    spade:  
     | 
| 
      
 42 
     | 
    
         
            +
                    tick: "√",
         
     | 
| 
      
 43 
     | 
    
         
            +
                    cross: "x",
         
     | 
| 
      
 44 
     | 
    
         
            +
                    star: "*",
         
     | 
| 
      
 45 
     | 
    
         
            +
                    square: "[█]",
         
     | 
| 
      
 46 
     | 
    
         
            +
                    square_empty: "[ ]",
         
     | 
| 
      
 47 
     | 
    
         
            +
                    dot: ".",
         
     | 
| 
      
 48 
     | 
    
         
            +
                    bullet: "O",
         
     | 
| 
      
 49 
     | 
    
         
            +
                    bullet_empty: "○",
         
     | 
| 
      
 50 
     | 
    
         
            +
                    marker: ">",
         
     | 
| 
      
 51 
     | 
    
         
            +
                    line: "-",
         
     | 
| 
      
 52 
     | 
    
         
            +
                    pipe: "|",
         
     | 
| 
      
 53 
     | 
    
         
            +
                    ellipsis: "...",
         
     | 
| 
      
 54 
     | 
    
         
            +
                    radio_on: "(*)",
         
     | 
| 
      
 55 
     | 
    
         
            +
                    radio_off: "( )",
         
     | 
| 
      
 56 
     | 
    
         
            +
                    checkbox_on: "[×]",
         
     | 
| 
      
 57 
     | 
    
         
            +
                    checkbox_off: "[ ]",
         
     | 
| 
      
 58 
     | 
    
         
            +
                    circle: "( )",
         
     | 
| 
      
 59 
     | 
    
         
            +
                    circle_on: "(x)",
         
     | 
| 
      
 60 
     | 
    
         
            +
                    circle_off: "( )",
         
     | 
| 
      
 61 
     | 
    
         
            +
                    arrow_up: "↑",
         
     | 
| 
      
 62 
     | 
    
         
            +
                    arrow_down: "↓",
         
     | 
| 
      
 63 
     | 
    
         
            +
                    arrow_up_down: "↕",
         
     | 
| 
      
 64 
     | 
    
         
            +
                    arrow_left: "←",
         
     | 
| 
      
 65 
     | 
    
         
            +
                    arrow_right: "→",
         
     | 
| 
      
 66 
     | 
    
         
            +
                    arrow_left_right: "↔",
         
     | 
| 
      
 67 
     | 
    
         
            +
                    heart: "♥",
         
     | 
| 
      
 68 
     | 
    
         
            +
                    diamond: "♦",
         
     | 
| 
      
 69 
     | 
    
         
            +
                    club: "♣",
         
     | 
| 
      
 70 
     | 
    
         
            +
                    spade: "♠"
         
     | 
| 
       71 
71 
     | 
    
         
             
                  }.freeze
         
     | 
| 
       72 
72 
     | 
    
         | 
| 
       73 
73 
     | 
    
         
             
                  def symbols
         
     | 
| 
         @@ -0,0 +1,36 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require "stringio"
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            require_relative "../prompt"
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            module TTY
         
     | 
| 
      
 8 
     | 
    
         
            +
              # Used for initializing test cases
         
     | 
| 
      
 9 
     | 
    
         
            +
              class Prompt
         
     | 
| 
      
 10 
     | 
    
         
            +
                module StringIOExtensions
         
     | 
| 
      
 11 
     | 
    
         
            +
                  def wait_readable(*)
         
     | 
| 
      
 12 
     | 
    
         
            +
                    true
         
     | 
| 
      
 13 
     | 
    
         
            +
                  end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                  def ioctl(*)
         
     | 
| 
      
 16 
     | 
    
         
            +
                    80
         
     | 
| 
      
 17 
     | 
    
         
            +
                  end
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                class Test < TTY::Prompt
         
     | 
| 
      
 21 
     | 
    
         
            +
                  def initialize(**options)
         
     | 
| 
      
 22 
     | 
    
         
            +
                    @input  = StringIO.new
         
     | 
| 
      
 23 
     | 
    
         
            +
                    @input.extend(StringIOExtensions)
         
     | 
| 
      
 24 
     | 
    
         
            +
                    @output = StringIO.new
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                    options.merge!({
         
     | 
| 
      
 27 
     | 
    
         
            +
                      input: @input,
         
     | 
| 
      
 28 
     | 
    
         
            +
                      output: @output,
         
     | 
| 
      
 29 
     | 
    
         
            +
                      env: { "TTY_TEST" => true },
         
     | 
| 
      
 30 
     | 
    
         
            +
                      enable_color: options.fetch(:enable_color) { true }
         
     | 
| 
      
 31 
     | 
    
         
            +
                    })
         
     | 
| 
      
 32 
     | 
    
         
            +
                    super(**options)
         
     | 
| 
      
 33 
     | 
    
         
            +
                  end
         
     | 
| 
      
 34 
     | 
    
         
            +
                end # Test
         
     | 
| 
      
 35 
     | 
    
         
            +
              end # Prompt
         
     | 
| 
      
 36 
     | 
    
         
            +
            end # TTY
         
     | 
    
        data/lib/tty/prompt/utils.rb
    CHANGED
    
    
    
        data/lib/tty/prompt/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,57 +1,43 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: tty-prompt
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.22.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Piotr Murach
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2020- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2020-07-20 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
     | 
    
         
            -
              name: necromancer
         
     | 
| 
       15 
     | 
    
         
            -
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       16 
     | 
    
         
            -
                requirements:
         
     | 
| 
       17 
     | 
    
         
            -
                - - "~>"
         
     | 
| 
       18 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       19 
     | 
    
         
            -
                    version: 0.5.0
         
     | 
| 
       20 
     | 
    
         
            -
              type: :runtime
         
     | 
| 
       21 
     | 
    
         
            -
              prerelease: false
         
     | 
| 
       22 
     | 
    
         
            -
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       23 
     | 
    
         
            -
                requirements:
         
     | 
| 
       24 
     | 
    
         
            -
                - - "~>"
         
     | 
| 
       25 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       26 
     | 
    
         
            -
                    version: 0.5.0
         
     | 
| 
       27 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       28 
14 
     | 
    
         
             
              name: pastel
         
     | 
| 
       29 
15 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       30 
16 
     | 
    
         
             
                requirements:
         
     | 
| 
       31 
17 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       32 
18 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       33 
     | 
    
         
            -
                    version: 0. 
     | 
| 
      
 19 
     | 
    
         
            +
                    version: '0.8'
         
     | 
| 
       34 
20 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       35 
21 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       36 
22 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       37 
23 
     | 
    
         
             
                requirements:
         
     | 
| 
       38 
24 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       39 
25 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       40 
     | 
    
         
            -
                    version: 0. 
     | 
| 
      
 26 
     | 
    
         
            +
                    version: '0.8'
         
     | 
| 
       41 
27 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       42 
28 
     | 
    
         
             
              name: tty-reader
         
     | 
| 
       43 
29 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       44 
30 
     | 
    
         
             
                requirements:
         
     | 
| 
       45 
31 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       46 
32 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       47 
     | 
    
         
            -
                    version: 0. 
     | 
| 
      
 33 
     | 
    
         
            +
                    version: '0.8'
         
     | 
| 
       48 
34 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       49 
35 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       50 
36 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       51 
37 
     | 
    
         
             
                requirements:
         
     | 
| 
       52 
38 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       53 
39 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       54 
     | 
    
         
            -
                    version: 0. 
     | 
| 
      
 40 
     | 
    
         
            +
                    version: '0.8'
         
     | 
| 
       55 
41 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       56 
42 
     | 
    
         
             
              name: rake
         
     | 
| 
       57 
43 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -70,14 +56,14 @@ dependencies: 
     | 
|
| 
       70 
56 
     | 
    
         
             
              name: rspec
         
     | 
| 
       71 
57 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       72 
58 
     | 
    
         
             
                requirements:
         
     | 
| 
       73 
     | 
    
         
            -
                - - " 
     | 
| 
      
 59 
     | 
    
         
            +
                - - ">="
         
     | 
| 
       74 
60 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       75 
61 
     | 
    
         
             
                    version: '3.0'
         
     | 
| 
       76 
62 
     | 
    
         
             
              type: :development
         
     | 
| 
       77 
63 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       78 
64 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       79 
65 
     | 
    
         
             
                requirements:
         
     | 
| 
       80 
     | 
    
         
            -
                - - " 
     | 
| 
      
 66 
     | 
    
         
            +
                - - ">="
         
     | 
| 
       81 
67 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       82 
68 
     | 
    
         
             
                    version: '3.0'
         
     | 
| 
       83 
69 
     | 
    
         
             
            description: A beautiful and powerful interactive command line prompt with a robust
         
     | 
| 
         @@ -101,17 +87,18 @@ files: 
     | 
|
| 
       101 
87 
     | 
    
         
             
            - lib/tty/prompt/choice.rb
         
     | 
| 
       102 
88 
     | 
    
         
             
            - lib/tty/prompt/choices.rb
         
     | 
| 
       103 
89 
     | 
    
         
             
            - lib/tty/prompt/confirm_question.rb
         
     | 
| 
      
 90 
     | 
    
         
            +
            - lib/tty/prompt/const.rb
         
     | 
| 
       104 
91 
     | 
    
         
             
            - lib/tty/prompt/converter_dsl.rb
         
     | 
| 
       105 
92 
     | 
    
         
             
            - lib/tty/prompt/converter_registry.rb
         
     | 
| 
       106 
93 
     | 
    
         
             
            - lib/tty/prompt/converters.rb
         
     | 
| 
       107 
94 
     | 
    
         
             
            - lib/tty/prompt/distance.rb
         
     | 
| 
       108 
95 
     | 
    
         
             
            - lib/tty/prompt/enum_list.rb
         
     | 
| 
      
 96 
     | 
    
         
            +
            - lib/tty/prompt/errors.rb
         
     | 
| 
       109 
97 
     | 
    
         
             
            - lib/tty/prompt/evaluator.rb
         
     | 
| 
       110 
98 
     | 
    
         
             
            - lib/tty/prompt/expander.rb
         
     | 
| 
       111 
99 
     | 
    
         
             
            - lib/tty/prompt/keypress.rb
         
     | 
| 
       112 
100 
     | 
    
         
             
            - lib/tty/prompt/list.rb
         
     | 
| 
       113 
101 
     | 
    
         
             
            - lib/tty/prompt/mask_question.rb
         
     | 
| 
       114 
     | 
    
         
            -
            - lib/tty/prompt/messages.rb
         
     | 
| 
       115 
102 
     | 
    
         
             
            - lib/tty/prompt/multi_list.rb
         
     | 
| 
       116 
103 
     | 
    
         
             
            - lib/tty/prompt/multiline.rb
         
     | 
| 
       117 
104 
     | 
    
         
             
            - lib/tty/prompt/paginator.rb
         
     | 
| 
         @@ -120,14 +107,15 @@ files: 
     | 
|
| 
       120 
107 
     | 
    
         
             
            - lib/tty/prompt/question/modifier.rb
         
     | 
| 
       121 
108 
     | 
    
         
             
            - lib/tty/prompt/question/validation.rb
         
     | 
| 
       122 
109 
     | 
    
         
             
            - lib/tty/prompt/result.rb
         
     | 
| 
      
 110 
     | 
    
         
            +
            - lib/tty/prompt/selected_choices.rb
         
     | 
| 
       123 
111 
     | 
    
         
             
            - lib/tty/prompt/slider.rb
         
     | 
| 
       124 
112 
     | 
    
         
             
            - lib/tty/prompt/statement.rb
         
     | 
| 
       125 
113 
     | 
    
         
             
            - lib/tty/prompt/suggestion.rb
         
     | 
| 
       126 
114 
     | 
    
         
             
            - lib/tty/prompt/symbols.rb
         
     | 
| 
      
 115 
     | 
    
         
            +
            - lib/tty/prompt/test.rb
         
     | 
| 
       127 
116 
     | 
    
         
             
            - lib/tty/prompt/timer.rb
         
     | 
| 
       128 
117 
     | 
    
         
             
            - lib/tty/prompt/utils.rb
         
     | 
| 
       129 
118 
     | 
    
         
             
            - lib/tty/prompt/version.rb
         
     | 
| 
       130 
     | 
    
         
            -
            - lib/tty/test_prompt.rb
         
     | 
| 
       131 
119 
     | 
    
         
             
            homepage: https://ttytoolkit.org
         
     | 
| 
       132 
120 
     | 
    
         
             
            licenses:
         
     | 
| 
       133 
121 
     | 
    
         
             
            - MIT
         
     |