pax_global_header 0000666 0000000 0000000 00000000064 14036620446 0014517 g ustar 00root root 0000000 0000000 52 comment=5152fb5abd4cb3a5aaefc31ec316618e1eb5787a tty-prompt-0.23.1/ 0000775 0000000 0000000 00000000000 14036620446 0013741 5 ustar 00root root 0000000 0000000 tty-prompt-0.23.1/.editorconfig 0000664 0000000 0000000 00000000226 14036620446 0016416 0 ustar 00root root 0000000 0000000 root = true [*.rb] charset = utf-8 end_of_line = lf insert_final_newline = true indent_style = space indent_size = 2 trim_trailing_whitespace = true tty-prompt-0.23.1/.github/ 0000775 0000000 0000000 00000000000 14036620446 0015301 5 ustar 00root root 0000000 0000000 tty-prompt-0.23.1/.github/FUNDING.yml 0000664 0000000 0000000 00000000024 14036620446 0017112 0 ustar 00root root 0000000 0000000 github: piotrmurach tty-prompt-0.23.1/.github/ISSUE_TEMPLATE.md 0000664 0000000 0000000 00000001137 14036620446 0020010 0 ustar 00root root 0000000 0000000 ### Are you in the right place? * For issues or feature requests file a GitHub issue in this repository * For general questions or discussion post in [Discussions](https://github.com/piotrmurach/tty-prompt/discussions) ### Describe the problem A brief description of the issue/feature. ### Steps to reproduce the problem ``` Your code here to reproduce the issue ``` ### Actual behaviour What happened? This could be a description, log output, error raised etc... ### Expected behaviour What did you expect to happen? ### Describe your environment * OS version: * Ruby version: * TTY::Prompt version: tty-prompt-0.23.1/.github/PULL_REQUEST_TEMPLATE.md 0000664 0000000 0000000 00000000756 14036620446 0021112 0 ustar 00root root 0000000 0000000 ### Describe the change What does this Pull Request do? ### Why are we doing this? Any related context as to why is this is a desirable change. ### Benefits How will the library improve? ### Drawbacks Possible drawbacks applying this change. ### Requirements - [ ] Tests written & passing locally? - [ ] Code style checked? - [ ] Rebased with `master` branch? - [ ] Documentation updated? - [ ] Changelog updated? tty-prompt-0.23.1/.github/workflows/ 0000775 0000000 0000000 00000000000 14036620446 0017336 5 ustar 00root root 0000000 0000000 tty-prompt-0.23.1/.github/workflows/ci.yml 0000664 0000000 0000000 00000002667 14036620446 0020467 0 ustar 00root root 0000000 0000000 --- name: CI on: push: branches: - master paths-ignore: - "benchmarks/**" - "examples/**" - "*.md" pull_request: branches: - master paths-ignore: - "benchmarks/**" - "examples/**" - "*.md" jobs: tests: name: Ruby ${{ matrix.ruby }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: - ubuntu-latest ruby: - 2.3 - 2.4 - 2.5 - 2.6 - 3.0 - ruby-head - jruby-9.2.13.0 - jruby-head - truffleruby-head include: - ruby: 2.1 os: ubuntu-latest coverage: false bundler: 1 - ruby: 2.2 os: ubuntu-latest coverage: false bundler: 1 - ruby: 2.7 os: ubuntu-latest coverage: true bundler: latest env: COVERAGE: ${{ matrix.coverage }} COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} continue-on-error: ${{ endsWith(matrix.ruby, 'head') }} steps: - uses: actions/checkout@v2 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} bundler: ${{ matrix.bundler }} - name: Install dependencies run: bundle install --jobs 4 --retry 3 - name: Run tests run: bundle exec rake ci tty-prompt-0.23.1/.gitignore 0000664 0000000 0000000 00000000223 14036620446 0015726 0 ustar 00root root 0000000 0000000 /.bundle/ /.ruby-version /.ruby-gemset /.yardoc /Gemfile.lock /_yardoc/ /coverage/ /doc/ /pkg/ /spec/reports/ /tmp/ *.bundle *.so *.o *.a mkmf.log tty-prompt-0.23.1/.rspec 0000664 0000000 0000000 00000000051 14036620446 0015052 0 ustar 00root root 0000000 0000000 --color --require spec_helper --warnings tty-prompt-0.23.1/.rubocop.yml 0000664 0000000 0000000 00000002602 14036620446 0016213 0 ustar 00root root 0000000 0000000 AllCops: NewCops: enable Layout/BlockAlignment: Exclude: - "spec/**/*" Layout/FirstArrayElementIndentation: Enabled: false Layout/FirstHashElementIndentation: Enabled: false Layout/HashAlignment: Exclude: - "spec/**/*" Layout/LineLength: Max: 80 Exclude: - "spec/**/*" Layout/SpaceInsideHashLiteralBraces: EnforcedStyle: no_space Lint/AssignmentInCondition: Enabled: false Lint/ConstantDefinitionInBlock: Exclude: - "spec/**/*" Metrics/AbcSize: Max: 35 Exclude: - "spec/**/*" Metrics/BlockLength: CountComments: true Max: 25 IgnoredMethods: [] Exclude: - "spec/**/*" Metrics/ClassLength: Max: 1500 Metrics/CyclomaticComplexity: Enabled: false Metrics/MethodLength: Max: 20 Exclude: - "spec/**/*" Naming/BinaryOperatorParameterName: Enabled: false Style/AccessorGrouping: Enabled: false Style/AccessModifierDeclarations: Enabled: false Style/AsciiComments: Enabled: false Style/BlockDelimiters: Enabled: false Style/CommentedKeyword: Enabled: false Style/FormatString: EnforcedStyle: percent Style/FormatStringToken: EnforcedStyle: template Style/HashConversion: Enabled: false Style/LambdaCall: EnforcedStyle: braces Exclude: - "spec/**/*" Style/StringLiterals: EnforcedStyle: double_quotes Style/StringConcatenation: Exclude: - "spec/**/*" Style/TrivialAccessors: Enabled: false tty-prompt-0.23.1/CHANGELOG.md 0000664 0000000 0000000 00000041206 14036620446 0015555 0 ustar 00root root 0000000 0000000 # Change log ## [v0.23.1] - 2021-04-17 ### Changed * Change validate to allow access to invalid input inside the message ### Fixed * Fix Choice#from to differentiate between no value being set and nil value ## [v0.23.0] - 2020-12-14 ### Added * Add the ability to provide an arbitrary array of values to Prompt::Slider by Katelyn Schiesser (@slowbro) ### Changed * Change to allow default option to be choice name as well as index in select, multi_select and enum_select prompts ### Fixed * Fix left and right key navigation while filtering choices in the #select and #multi_select prompts ## [v0.22.0] - 2020-07-20 ### Added * Add #slider format customization with a proc by Sven Pchnit(@2called-chaos) * Add convert message customization * Add conversion of input into Array, Hash or URI object * Add callable objects as possible values in :active_color and :help_color * Add shortcuts to select of all/reverse choices in #multi_select prompt * Add :help option to #slider prompt * Add :quiet option to remove final prompt output by Katelyn Schiesser (@slowbro) * Add :show_help option to control help display in #select, #multi_select, #enum_select and #slider prompts ### Changed * Changed question :validation option to :validate by Sven Pachnit(@2called-chaos) * Change ConverterRegistry to store only proc values and simplify interface * Change Converters to stop raising errors and print console error messages instead * Change :range conversion to handle float numbers * Change yes?/no? prompt to infer default value from words and raise when no boolean can be deduced * Change Prompt#new to use keyword arguments * Change #select/#multi_select prompts default help text * Change #multi_select to preserve original ordering in returned answers * Change to remove necromancer dependency * Change TTY::TestPrompt to TTY::Prompt::Test * Change #select,#multi_select & #enum_select to allow mix of options and block parameters configuration * Change to allow filtering through symbol choice names * Change all errors to inherit from common Error class ### Fixed * Fix multiline prompt to return default value when no input provided * Fix color option overriding in say, ok, error and warn prompts * Fix Prompt#inspect format to display all public attributes ## [v0.21.0] - 2020-03-08 ### Added * Add :min option to #multi_select prompt by Katelyn Schiesser(@slowbro) ### Changed * Change gemspec to remove test artifacts ### Fixed * Fix :help_color option for multi_select prompt by @robbystk ## [v0.20.0] - 2019-11-24 ### Changed * Change to update tty-reader dependency * Change gemspec to include metadata ### Fixed * Fix Choice#from to differentiate between nil and false by Katelyn Schiesser(@slowbro) * Fix yes? and no? prompts to stop raising on invalid/blank input by Katelyn Schiesser(@slowbro) * Fix Ruby 2.7 keyword arguments warnings * Fix question validation to work with nil input ## [v0.19.0] - 2019-05-27 ### Added * Add Prompt#debug to allow displaying values in terminal's top right corner * Add :max to limit number of choices in #multi_select prompt * Add :value to pre populate #ask prompt line content * Add :auto_hint to expand default hint in #expand prompt by Ewoudt Kellerman(@hellola) * Add Timer to track and timeout code execution ### Changed * Change Paginator to expose #start_index & #end_index * Change Paginator to figure out #start_index based on per page size and adjust boundaries to match active selection * Change #ask prompt to allow no question * Change #enum_select to automatically assigned non-disabled default option * Change #enum_select to set default choice when navigating by page * Change #select & #multi_select to allow navigation by page with left/right keys * Change #keypress to use Timer * Change Choice#from to allow any object coercible to string * Change to remove test artifacts from the gem bundle * Change to remove timers dependency * Change to update tty-reader dependency ## [v0.18.1] - 2018-12-29 ### Changed * Change #multi_select & #select to auto select first non-disabled active choice ### Fixed * Fix #select, #multi_select & #enum_select to allow for symbols as choice names ## [v0.18.0] - 2018-11-24 ### Changed * Change to update tty-reader dependency * Remove encoding magic comments ### Fixed * Fix #keypress to stop using the :nonblock option * Fix input reading to correctly capture the Esc key(#84) * Fix line editing when cursor is on second to last character(#94) ## [v0.17.2] - 2018-11-01 ### Fixed * Fix #yes? & #no? prompt suffix option to all non-standard characters by Rui(@rpbaltazar) ## [v0.17.1] - 2018-10-03 ### Change * Change #select, #multi_select to allow alphanumeric, punctuation and space characters in filters ### Fixed * Fix #select by making filter an array to avoid frozen string issues by Chris Hoffman(@yarmiganosca) ## [v0.17.0] - 2018-08-05 ### Changed * Change to update tty-reader & tty-cursor dependencies * Change to directly require files in gemspec ## [v0.16.1] - 2018-04-29 ### Fixed * Fix key events subscription to only listen for the current prompt events ## [v0.16.0] - 2018-03-11 ### Added * Add :disabled key to Choice * Add ability to disable choices in #select, #multi_selct & #enum_select prompts * Add #frozen_string_literal to all files ### Changed * Change Choice#from to allow parsing different data structures * Change all classes to prevent strings mutations * Change Timeout to cleanly terminate keypress input without raising errors ### Fixed * Fix #select, #enum_select & #multi_select navigation to work correctly with items longer than terminal screen width * Fix timeout on Ruby 2.5 and stop raising Timeout::Error ## [v0.15.0] - 2018-02-08 ### Added * Add ability to filter list items in #select, #multi_select & #enum_selct prompts by Saverio Miroddi(@saveriomiroddi) * Add support for array of values for an answer collector key by Danny Hadley(@dadleyy) ### Changed * Relax dependency on timers by Andy Brody(@brodygov) ## [v0.14.0] - 2018-01-01 ### Added * Add :cycle option to #select, #multi_select & #enum_select prompts to allow toggling between infinite and bounded list by Jonas Müller(@muellerj) ### Changed * Change #multi_selct, #select & #enum_select to stop cycling options by default by Jona Müller(@muellerj) * Change gemspec to require ruby >= 2.0.0 * Change #slider prompt to display slider next to query and help underneath * Change to use tty-reader v0.2.0 with new line editing features for processing long inputs ### Fixed * Fix Paginator & EnumPaginator to allow only positive integer values by Andy Brody(@ab) * Fix EnumSelect to report on default option out of range and raise correctly * Fix #ask :file & :path converters to correctly locate the files * Fix #ask, #multiline to correctly handle long strings that wrap around screen * Fix #slider prompt to correctly scale sliding ## [v0.13.2] - 2017-08-30 ### Changed * Change to extract TTY::Prompt::Reader to its own dependency ## [v0.13.1] - 2017-08-16 ### Added * Add ability to manually cancel the time scheduler ### Changed * Change #keypress to use new scheduler cancelling * Change Reader to inline interrupt to allow for early exit ### Fix * Fix keypress reading on Windows to distinguish between blocking & non-blocking IO ## [v0.13.0] - 2017-08-11 ### Changed * Change Timeout to use clock time instead of sleep to measure interval * Upgrade tty-cursor to fix save & restore ### Fixed * Fix keypress with timeout option to cleanly stop timeout thread * Fix Reader on Windows to stop blocking when waiting for key press ## [v0.12.0] - 2017-03-19 ### Added * Add Multiline question type * Add Keypress question type * Add Reader::History for storing buffered lines * Add Reader::Line for line abstraction ### Changed * Remove :read option from Question * Chnage Reader#read_line to handle raw mode for processing special characters such as Ctrl+x, navigate through history buffer using up/down arrows, allow editing current line by moving left/right with arrow keys and inserting content * Change Reader#read_multiline to gather multi line input correctly, skip empty lines and terminate when Ctrl+d and Ctrl+z are pressed * Change Reader::Mode to check if tty is available by Matt Martyn (@MMartyn) * Change #keypress prompt to correctly refresh line and accept :keys & :timeout options ### Fixed * Fix issue with #select, #multi_selct, #enum_select when choices are provided as hash object together with prompt options. * Fix issue with default parameter for yes?/no? prompt by Carlos Fonseca (@carlosefonseca) * Fix List#help to allow setting help text through DSL ## [v0.11.0] - 2017-02-26 ### Added * Add Console for reading input characters on Unix systems * Add WinConsole for reading input characters on Windows systems * Add WindowsApi to allow for calls to external Windows api * Add echo support to multilist by Keith Keith T. Garner(@ktgeek) ### Changed * Change Reader to use Console for input reading * Change Codes to use codepoints instead of strings * Change Reader#read_line to match #gets behaviour * Change Symbols to provide Unicode support on windows * Change Slider to display Unicode when possible * Change ConverterRegistry to be immutable * Change Reader to expose #trigger in place of #publish for events firing ### Fixed * Fix `modify` throwing exception, when user enters empty input by Igor Rzegocki(@ajgon) * Fix #clear_line behaviour by using tty-cursor 0.4.0 to work in all terminals * Fix paging issue for lists shorter than :per_page value repeating title * Fix #mask prompt to correctly match input on Windows * Fix @mask to use default error messages * Fix #select & #multi_select prompts to allow changing options with arrow keys on Windows * Fix #echo to work correctly in zsh shell by štef(@d4be4st) * Fix Slider#keyright event accepting max value outside of range * Fix 2.4.0 conversion errors by using necromancer 0.4.0 * Fix #enum_select preventing selection of first item ## [v0.10.1] - 2017-02-06 ### Fixed * Fix File namespacing ## [v0.10.0] - 2017-01-01 ### Added * Add :enable_color option for toggling colors support ### Changed * Update pastel dependency version ## [v0.9.0] - 2016-12-20 ### Added * Add ability to paginate choices list for #select, #multi_select & #enum_select with :per_page, :page_info and :default options * Add ability to switch through options in #select & #multi_select using the tab key ### Fixed * Fix readers to accept multibyte characters reported by Jaehyun Shin(@keepcosmos) ## [v0.8.0] - 2016-11-29 ### Added * Add ability to publish custom key events for VIM keybindings customisations etc... ### Fixed * Fix Reader#read_char to use Ruby internal buffers instead of direct system call by @kke(Kimmo Lehto) * Fix issue with #ask required & validate checks to take into account required when validating values * Fix bug with #read_keypress to handle function keys and meta navigation keys * Fix issue with default messages not displaying for `range`, `required` and `validate` ## [v0.7.1] - 2016-08-07 ### Fixed * Fix Reader::Mode to include standard io library ## [v0.7.0] - 2016-07-17 ### Added * Add :interrupt_handler option to customise keyboard interrupt behaviour ### Changed * Remove tty-platform dependency ### Fixed * Fix Reader#read_keypress issue when handling interrupt signal by Ondrej Moravcik(@ondra-m) * Fix raw & echo modes to use standard library support by Kim Burgestrand(@Burgestrand) ## [v0.6.0] - 2016-05-21 ### Changed * Upgrade tty-cursor dependency ### Fixed * Fix issue with reader trapping signals by @kylekyle * Fix expand to use new prev_line implementation ## [v0.5.0] - 2016-03-28 ### Added * Add ConfirmQuestion for #yes? & #no? calls * Add ability to collect more than one answer through #collect call * Add Choices#find_by for selecting choice based on attribute * Add Prompt#expand for expanding key options * Add :active_color, :help_color, :prefix options for customizing prompts display ### Changed * Change Choice#from to allow for coersion of complex objects with keys * Change Choices#pluck to search through object attributes * Change #select :enum option help text to display actual numbers range ### Fixed * Fix #no? to correctly ask negative question by @ondra-m * Fix #ask :default option to handle nil or empty string * Fix #multi_select :default option and color changing ## [v0.4.0] - 2016-02-08 ### Added * Add :enum option for #select & #multi_select to allow for numerical selection by @rtoshiro * Add new key event types to KeyEvent * Add #slider for picking values from range of numbers * Add #enum_select for selecting option from enumerated list * Add ability to configure error messages for #ask call * Add new ConversionError type ### Changed * Move #blank? to Utils * Update pastel dependency ## [v0.3.0] - 2015-12-28 ### Added * Add prefix option to prompt to customize #ask, #select, #multi_select * Add default printing to #ask * Add #yes?/#no? boolean queries * Add Evaluator and Result for validation checking to Question * Add ability for #ask to display error messages on failed validation * Add ability to specify in-built names for validation e.i. :email * Add KeyEvent for keyboard events publishing to Reader * Add #read_multiline to Reader * Add :convert option for ask configuration * Add ability to specify custom proc converters * Add #ask_keypress to gather character input * Add #ask_multiline to gather multiline input * Add MaskedQuestion & #mask method for masking input stream characters ### Changed * Change Reader#read_keypress to be robust and read correctly byte sequences * Change Reader#getc to #read_line and extend arguments with echo option * Extract cursor movement to dependency tty-cursor * Change List & MultiList to subscribe to keyboard events * Change to move mode inside reader namespace * Remove Response & Error objects * Remove :char option from #ask * Change :read option to specify mode of reading out of :line, :multiline, :keypress * Rename #confirm to #ok ## [v0.2.0] - 2015-11-23 ### Added * Add ability to select choice form list #select * Add ability to select multiple options #multi_select * Add :read option to #ask for reading specific type input ### Changed * Change #ask api to be similar to #select and #multi_select behaviour * Change #ask :argument option to be :required * Remove :valid option from #ask as #select is a better solution ## [v0.1.0] - 2015-11-01 * Initial implementation and release [v0.23.1]: https://github.com/piotrmurach/tty-prompt/compare/v0.23.0...v0.23.1 [v0.23.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.22.0...v0.23.0 [v0.22.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.21.0...v0.22.0 [v0.21.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.20.0...v0.21.0 [v0.20.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.19.0...v0.20.0 [v0.19.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.18.1...v0.19.0 [v0.18.1]: https://github.com/piotrmurach/tty-prompt/compare/v0.18.0...v0.18.1 [v0.18.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.17.2...v0.18.0 [v0.17.2]: https://github.com/piotrmurach/tty-prompt/compare/v0.17.1...v0.17.2 [v0.17.1]: https://github.com/piotrmurach/tty-prompt/compare/v0.17.0...v0.17.1 [v0.17.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.16.1...v0.17.0 [v0.16.1]: https://github.com/piotrmurach/tty-prompt/compare/v0.16.0...v0.16.1 [v0.16.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.15.0...v0.16.0 [v0.15.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.14.0...v0.15.0 [v0.14.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.13.2...v0.14.0 [v0.13.2]: https://github.com/piotrmurach/tty-prompt/compare/v0.13.1...v0.13.2 [v0.13.1]: https://github.com/piotrmurach/tty-prompt/compare/v0.13.0...v0.13.1 [v0.13.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.12.0...v0.13.0 [v0.12.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.11.0...v0.12.0 [v0.11.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.10.1...v0.11.0 [v0.10.1]: https://github.com/piotrmurach/tty-prompt/compare/v0.10.0...v0.10.1 [v0.10.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.9.0...v0.10.0 [v0.9.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.8.0...v0.9.0 [v0.8.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.7.1...v0.8.0 [v0.7.1]: https://github.com/piotrmurach/tty-prompt/compare/v0.7.0...v0.7.1 [v0.7.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.6.0...v0.7.0 [v0.6.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.5.0...v0.6.0 [v0.5.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.4.0...v0.5.0 [v0.4.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.3.0...v0.4.0 [v0.3.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.2.0...v0.3.0 [v0.2.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.1.0...v0.2.0 [v0.1.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.1.0 tty-prompt-0.23.1/CODE_OF_CONDUCT.md 0000664 0000000 0000000 00000006240 14036620446 0016542 0 ustar 00root root 0000000 0000000 # Contributor Covenant Code of Conduct ## Our Pledge In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards Examples of behavior that contributes to creating a positive environment include: * Using welcoming and inclusive language * Being respectful of differing viewpoints and experiences * Gracefully accepting constructive criticism * Focusing on what is best for the community * Showing empathy towards other community members Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery and unwelcome sexual attention or advances * Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or electronic address, without explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. ## Scope This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at piotr@piotrmurach.com. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [https://contributor-covenant.org/version/1/4][version] [homepage]: https://contributor-covenant.org [version]: https://contributor-covenant.org/version/1/4/ tty-prompt-0.23.1/Gemfile 0000664 0000000 0000000 00000000637 14036620446 0015242 0 ustar 00root root 0000000 0000000 source "https://rubygems.org" gemspec # gem "tty-reader", git: "https://github.com/piotrmurach/tty-reader" # gem "pastel", git: "https://github.com/piotrmurach/pastel" gem "json", "2.4.1" if RUBY_VERSION == "2.0.0" group :test do gem "benchmark-ips", "~> 2.7.2" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.5.0") gem "coveralls_reborn", "~> 0.21.0" gem "simplecov", "~> 0.21.0" end end tty-prompt-0.23.1/LICENSE.txt 0000664 0000000 0000000 00000002077 14036620446 0015572 0 ustar 00root root 0000000 0000000 Copyright (c) 2015 Piotr Murach (piotrmurach.com) MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. tty-prompt-0.23.1/README.md 0000664 0000000 0000000 00000141045 14036620446 0015225 0 ustar 00root root 0000000 0000000
# TTY::Prompt [][gitter] [][gem] [][gh_actions_ci] [][appveyor] [][codeclimate] [][coverage] [][inchpages] [gitter]: https://gitter.im/piotrmurach/tty [gem]: http://badge.fury.io/rb/tty-prompt [gh_actions_ci]: https://github.com/piotrmurach/tty-prompt/actions?query=workflow%3ACI [travis]: http://travis-ci.org/piotrmurach/tty-prompt [appveyor]: https://ci.appveyor.com/project/piotrmurach/tty-prompt [codeclimate]: https://codeclimate.com/github/piotrmurach/tty-prompt [coverage]: https://coveralls.io/github/piotrmurach/tty-prompt [inchpages]: http://inch-ci.org/github/piotrmurach/tty-prompt > A beautiful and powerful interactive command line prompt. **TTY::Prompt** provides independent prompt component for [TTY](https://github.com/piotrmurach/tty) toolkit. ## Features * Number of prompt types for gathering user input * A robust API for validating complex inputs * User friendly error feedback * Intuitive DSL for creating complex menus * Ability to page long menus * Support for Linux, OS X, FreeBSD and Windows systems ## Windows support `tty-prompt` works across all Unix and Windows systems in the "best possible" way. On Windows, it uses Win32 API in place of terminal device to provide matching functionality. Since Unix terminals provide richer set of features than Windows PowerShell consoles, expect to have a better experience on Unix-like platform. Some features like `select` or `multi_select` menus may not work on Windows when run from Git Bash. See GitHub suggested [fixes](https://github.com/git-for-windows/git/wiki/FAQ#some-native-console-programs-dont-work-when-run-from-git-bash-how-to-fix-it). For Windows, consider installing [ConEmu](https://conemu.github.io/), [cmder](http://cmder.net/) or [PowerCmd](http://www.powercmd.com/). ## Installation Add this line to your application's Gemfile: ```ruby gem "tty-prompt" ``` And then execute: $ bundle Or install it yourself as: $ gem install tty-prompt ## Contents * [1. Usage](#1-usage) * [2. Interface](#2-interface) * [2.1 ask](#21-ask) * [2.1.1 :convert](#211-convert) * [2.1.2 :default](#212-default) * [2.1.3 :value](#213-value) * [2.1.4 :echo](#214-echo) * [2.1.5 error messages](#215-error-messages) * [2.1.6 :in](#216-in) * [2.1.7 :modify](#217-modify) * [2.1.8 :required](#218-required) * [2.1.9 :validate](#219-validate) * [2.2 keypress](#22-keypress) * [2.2.1 :timeout](#221-timeout) * [2.3 multiline](#23-multiline) * [2.4 mask](#24-mask) * [2.5 yes?/no?](#25-yesno) * [2.6 menu](#26-menu) * [2.6.1 choices](#261-choices) * [2.6.1.1 :disabled](#2611-disabled) * [2.6.2 select](#262-select) * [2.6.2.1 :cycle](#2621-cycle) * [2.6.2.2 :enum](#2622-enum) * [2.6.2.3 :help](#2623-help) * [2.6.2.4 :marker](#2624-marker) * [2.6.2.5 :per_page](#2625-per_page) * [2.6.2.6 :disabled](#2626-disabled) * [2.6.2.7 :filter](#2627-filter) * [2.6.3 multi_select](#263-multi_select) * [2.6.3.1 :cycle](#2631-cycle) * [2.6.3.2 :enum](#2632-enum) * [2.6.3.3 :help](#2633-help) * [2.6.3.4 :per_page](#2634-per_page) * [2.6.3.5 :disabled](#2635-disabled) * [2.6.3.6 :echo](#2636-echo) * [2.6.3.7 :filter](#2637-filter) * [2.6.3.8 :min](#2638-min) * [2.6.3.9 :max](#2639-max) * [2.6.4 enum_select](#264-enum_select) * [2.6.4.1 :per_page](#2641-per_page) * [2.6.4.1 :disabled](#2641-disabled) * [2.7 expand](#27-expand) * [2.7.1 :auto_hint](#271-auto_hint) * [2.8 collect](#28-collect) * [2.9 suggest](#29-suggest) * [2.10 slider](#210-slider) * [2.11 say](#211-say) * [2.11.1 ok](#2111-ok) * [2.11.2 warn](#2112-warn) * [2.11.3 error](#2113-error) * [2.12 keyboard events](#212-keyboard-events) * [3. settings](#3-settings) * [3.1 :symbols](#31-symbols) * [3.2 :active_color](#32-active_color) * [3.3 :enable_color](#33-enable_color) * [3.4 :help_color](#34-help_color) * [3.5 :interrupt](#35-interrupt) * [3.6 :prefix](#36-prefix) * [3.7 :quiet](#37-quiet) * [3.8 :track_history](#38-track_history) ## 1. Usage In order to start asking questions on the command line, create prompt: ```ruby require "tty-prompt" prompt = TTY::Prompt.new ``` And then call `ask` with the question for simple input: ```ruby prompt.ask("What is your name?", default: ENV["USER"]) # => What is your name? (piotr) ``` To confirm input use `yes?`: ```ruby prompt.yes?("Do you like Ruby?") # => Do you like Ruby? (Y/n) ``` If you want to input password or secret information use `mask`: ```ruby prompt.mask("What is your secret?") # => What is your secret? •••• ``` Asking question with list of options couldn't be easier using `select` like so: ```ruby prompt.select("Choose your destiny?", %w(Scorpion Kano Jax)) # => # Choose your destiny? (Use ↑/↓ arrow keys, press Enter to select) # ‣ Scorpion # Kano # Jax ``` Also, asking multiple choice questions is a breeze with `multi_select`: ```ruby choices = %w(vodka beer wine whisky bourbon) prompt.multi_select("Select drinks?", choices) # => # # Select drinks? (Use ↑/↓ arrow keys, press Space to select and Enter to finish)" # ‣ ⬡ vodka # ⬡ beer # ⬡ wine # ⬡ whisky # ⬡ bourbon ``` To ask for a selection from enumerated list you can use `enum_select`: ```ruby choices = %w(emacs nano vim) prompt.enum_select("Select an editor?", choices) # => # # Select an editor? # 1) emacs # 2) nano # 3) vim # Choose 1-3 [1]: ``` However, if you have a lot of options to choose from you may want to use `expand`: ```ruby choices = [ { key: "y", name: "overwrite this file", value: :yes }, { key: "n", name: "do not overwrite this file", value: :no }, { key: "a", name: "overwrite this file and all later files", value: :all }, { key: "d", name: "show diff", value: :diff }, { key: "q", name: "quit; do not overwrite this file ", value: :quit } ] prompt.expand("Overwrite Gemfile?", choices) # => # Overwrite Gemfile? (enter "h" for help) [y,n,a,d,q,h] ``` If you wish to collect more than one answer use `collect`: ```ruby result = prompt.collect do key(:name).ask("Name?") key(:age).ask("Age?", convert: :int) key(:address) do key(:street).ask("Street?", required: true) key(:city).ask("City?") key(:zip).ask("Zip?", validate: /\A\d{3}\Z/) end end # => # {:name => "Piotr", :age => 30, :address => {:street => "Street", :city => "City", :zip => "123"}} ``` ## 2. Interface ### 2.1 ask In order to ask a basic question do: ```ruby prompt.ask("What is your name?") ``` However, to prompt for more complex input you can use robust API by passing hash of properties or using a block like so: ```ruby prompt.ask("What is your name?") do |q| q.required true q.validate /\A\w+\Z/ q.modify :capitalize end ``` #### 2.1.1 `:convert` The `convert` property is used to convert input to a required type. By default no conversion of input is performed. To change this use one of the following conversions: * `:boolean`|`:bool` - e.g. 'yes/1/y/t/' becomes `true`, 'no/0/n/f' becomes `false` * `:date` - parses dates formats "28/03/2020", "March 28th 2020" * `:time` - parses time formats "11:20:03" * `:float` - e.g. `-1` becomes `-1.0` * `:int`|`:integer` - e.g. `+1` becomes `1` * `:sym`|`:symbol` - e.g. "foo" becomes `:foo` * `:filepath` - converts to file path * `:path`|`:pathname` - converts to `Pathname` object * `:range` - e.g. '1-10' becomes `1..10` range object * `:regexp` - e.g. "foo|bar" becomes `/foo|bar/` * `:uri` - converts to `URI` object * `:list`|`:array` - e.g. 'a,b,c' becomes `["a", "b", "c"]` * `:map`|`:hash` - e.g. 'a:1 b:2 c:3' becomes `{a: "1", b: "2", c: "3"}` In addition you can specify a plural or append `list` or `array` to any base type: * `:ints` or `:int_list` - will convert to a list of integers * `:floats` or `:float_list` - will convert to a list of floats * `:bools` or `:bool_list` - will convert to a list of booleans, e.g. `t,f,t` becomes `[true, false, true]` Similarly, you can append `map` or `hash` to any base type: * `:int_map`|`:integer_map`|`:int_hash` - will convert to a hash of integers, e.g `a:1 b:2 c:3` becomes `{a: 1, b: 2, c: 3}` * `:bool_map` | `:boolean_map`|`:bool_hash` - will convert to a hash of booleans, e.g `a:t b:f c:t` becomes `{a: true, b: false, c: true}` By default, `map` converts keys to symbols, if you wish to use strings instead specify key type like so: * `:str_int_map` - will convert to a hash of string keys and integer values * `:string_integer_hash` - will convert to a hash of string keys and integer values For example, if you are interested in range type as answer do the following: ```ruby prompt.ask("Provide range of numbers?", convert: :range) # Provide range of numbers? 1-10 # => 1..10 ``` If, on the other hand, you wish to convert input to a hash of integer values do: ```ruby prompt.ask("Provide keys and values:", convert: :int_map) # Provide keys and values: a=1 b=2 c=3 # => {a: 1, b: 2, c: 3} ``` If a user provides a wrong type for conversion an error message will be printed in the console: ```ruby prompt.ask("Provide digit:", convert: :float) # Provide digit: x # >> Cannot convert `x` into 'float' type ``` You can further customize error message: ```ruby prompt.ask("Provide digit:", convert: :float) do |q| q.convert(:float, "Wrong value of %{value} for %{type} conversion") # or q.convert :float q.messages[:convert?] = "Wrong value of %{value} for %{type} conversion" end ``` You can also provide a custom conversion like so: ```ruby prompt.ask("Ingredients? (comma sep list)") do |q| q.convert -> (input) { input.split(/,\s*/) } end # Ingredients? (comma sep list) milk, eggs, flour # => ["milk", "eggs", "flour"] ``` #### 2.1.2 `:default` The `:default` option is used if the user presses return key: ```ruby prompt.ask("What is your name?", default: "Anonymous") # => # What is your name? (Anonymous) ``` #### 2.1.3 `:value` To pre-populate the input line for editing use `:value` option: ```ruby prompt.ask("What is your name?", value: "Piotr") # => # What is your name? Piotr ``` #### 2.1.4 `:echo` To control whether the input is shown back in terminal or not use `:echo` option like so: ```ruby prompt.ask("password:", echo: false) ``` #### 2.1.5 error messages By default `tty-prompt` comes with predefined error messages for `convert`, `required`, `in`, `validate` options. You can change these and configure to your liking either by passing message as second argument with the option: ```ruby prompt.ask("What is your email?") do |q| q.validate(/\A\w+@\w+\.\w+\Z/, "Invalid email address") end ``` Or change the `messages` key entry out of `:convert?`, `:range?`, `:required?` and `:valid?`: ```ruby prompt.ask("What is your email?") do |q| q.validate(/\A\w+@\w+\.\w+\Z/) q.messages[:valid?] = "Invalid email address" end ``` To change default range validation error message do: ```ruby prompt.ask("How spicy on scale (1-5)? ") do |q| q.in "1-5" q.messages[:range?] = "%{value} out of expected range %{in}" end ``` #### 2.1.6 `:in` In order to check that provided input falls inside a range of inputs use the `in` option. For example, if we wanted to ask a user for a single digit in given range we may do following: ```ruby prompt.ask("Provide number in range: 0-9?") { |q| q.in("0-9") } ``` #### 2.1.7 `:modify` Set the `:modify` option if you want to handle whitespace or letter capitalization. ```ruby prompt.ask("Enter text:") do |q| q.modify :strip, :collapse end ``` Available letter casing settings are: ```ruby :up # change to upper case :down # change to small case :capitalize # capitalize each word ``` Available whitespace settings are: ```ruby :trim # remove whitespace from both ends of the input :strip # same as :trim :chomp # remove whitespace at the end of input :collapse # reduce all whitespace to single character :remove # remove all whitespace ``` #### 2.1.8 `:required` To ensure that input is provided use `:required` option: ```ruby prompt.ask("What's your phone number?", required: true) # What's your phone number? # >> Value must be provided ``` #### 2.1.9 `:validate` In order to validate that input matches a given pattern you can pass the `validate` option/method. Validate accepts `Regex`, `Proc` or `Symbol`. ```ruby prompt.ask("What is your username?") do |q| q.validate(/\A[^.]+\.[^.]+\Z/) end ``` The above can also be expressed as a `Proc`: ```ruby prompt.ask("What is your username?") do |q| q.validate ->(input) { input =~ /\A[^.]+\.[^.]+\Z/ } end ``` There is a built-in validation for `:email` and you can use it directly like so: ```ruby prompt.ask("What is your email?") { |q| q.validate :email } ``` The default validation message is `"Your answer is invalid (must match %{valid})"` and you can customise it by passing in a second argument: ```ruby prompt.ask("What is your username?") do |q| q.validate(/\A[^.]+\.[^.]+\Z/, "Invalid username: %{value}, must match %{valid}") end ``` The default message can also be set using `messages` and the `:valid?` key: ```ruby prompt.ask("What is your username?") do |q| q.validate(/\A[^.]+\.[^.]+\Z/) q.messages[:valid?] = "Invalid username: %{value}, must match %{valid}") end ``` ### 2.2. keypress In order to ask question that awaits a single character answer use `keypress` prompt like so: ```ruby prompt.keypress("Press key ?") # Press key? # => a ``` By default any key is accepted but you can limit keys by using `:keys` option. Any key event names such as `:space` or `:ctrl_k` are valid: ```ruby prompt.keypress("Press space or enter to continue", keys: [:space, :return]) ``` #### 2.2.1 timeout Timeout can be set using `:timeout` option to expire prompt and allow the script to continue automatically: ```ruby prompt.keypress("Press any key to continue, resumes automatically in 3 seconds ...", timeout: 3) ``` In addition the `keypress` recognises `:countdown` token when inserted inside the question. It will automatically countdown the time in seconds: ```ruby prompt.keypress("Press any key to continue, resumes automatically in :countdown ...", timeout: 3) ``` ### 2.3 multiline Asking for multiline input can be done with `multiline` method. The reading of input will terminate when `Ctrl+d` or `Ctrl+z` is pressed. Empty lines will not be included in the returned array. ```ruby prompt.multiline("Description?") # Description? (Press CTRL-D or CTRL-Z to finish) # I know not all that may be coming, # but be it what it will, # I'll go to it laughing. # => # ["I know not all that may be coming,\n", "but be it what it will,\n", "I'll go to it laughing.\n"] ``` The `multiline` uses similar options to those supported by `ask` prompt. For example, to provide default description: ```ruby prompt.multiline("Description?", default: "A super sweet prompt.") ``` Or using DSL: ```ruby prompt.multiline("Description?") do |q| q.default "A super sweet prompt." q.help "Press thy ctrl+d to end" end ``` ### 2.4 mask If you require input of confidential information use `mask` method. By default each character that is printed is replaced by `•` symbol. All configuration options applicable to `ask` method can be used with `mask` as well. ```ruby prompt.mask("What is your secret?") # => What is your secret? •••• ``` The masking character can be changed by passing the `:mask` key: ```ruby heart = prompt.decorate(prompt.symbols[:heart] + " ", :magenta) prompt.mask("What is your secret?", mask: heart) # => What is your secret? ❤ ❤ ❤ ❤ ❤ ``` If you don't wish to show any output use `:echo` option like so: ```ruby prompt.mask("What is your secret?", echo: false) ``` You can also provide validation for your mask to enforce for instance strong passwords: ```ruby prompt.mask("What is your secret?", mask: heart) do |q| q.validate(/[a-z\ ]{5,15}/) end ``` ### 2.5 yes?/no? In order to display a query asking for boolean input from user use `yes?` like so: ```ruby prompt.yes?("Do you like Ruby?") # => # Do you like Ruby? (Y/n) ``` You can further customize question by passing `suffix`, `positive`, `negative` and `convert` options. The `suffix` changes text of available options, the `positive` specifies display string for successful answer and `negative` changes display string for negative answer. The final value is a boolean provided the `convert` option evaluates to boolean. It's enough to provide the `suffix` option for the prompt to accept matching answers with correct labels: ```ruby prompt.yes?("Are you a human?") do |q| q.suffix "Yup/nope" end # => # Are you a human? (Yup/nope) ``` Alternatively, instead of `suffix` option provide the `positive` and `negative` labels: ```ruby prompt.yes?("Are you a human?") do |q| q.default false q.positive "Yup" q.negative "Nope" end # => # Are you a human? (yup/Nope) ``` Finally, providing all available options you can ask fully customized question: ```ruby prompt.yes?("Are you a human?") do |q| q.suffix "Agree/Disagree" q.positive "Agree" q.negative "Disagree" q.convert -> (input) { !input.match(/^agree$/i).nil? } end # => # Are you a human? (Agree/Disagree) ``` There is also the opposite for asking confirmation of negative question: ```ruby prompt.no?("Do you hate Ruby?") # => # Do you hate Ruby? (y/N) ``` Similarly to `yes?` method, you can supply the same options to customize the question. ### 2.6 menu ### 2.6.1 choices There are many ways in which you can add menu choices. The simplest way is to create an array of values: ```ruby choices = %w(small medium large) ``` By default the choice name is also the value the prompt will return when selected. To provide custom values, you can provide a hash with keys as choice names and their respective values: ```ruby choices = {small: 1, medium: 2, large: 3} prompt.select("What size?", choices) # => # What size? (Press ↑/↓ arrow to move and Enter to select) # ‣ small # medium # large ``` Finally, you can define an array of choices where each choice is a hash value with `:name` & `:value` keys which can include other options for customising individual choices: ```ruby choices = [ {name: "small", value: 1}, {name: "medium", value: 2, disabled: "(out of stock)"}, {name: "large", value: 3} ] ``` You can specify `:key` as an additional option which will be used as short name for selecting the choice via keyboard key press. Another way to create menu with choices is using the DSL and the `choice` method. For example, the previous array of choices with hash values can be translated as: ```ruby prompt.select("What size?") do |menu| menu.choice name: "small", value: 1 menu.choice name: "medium", value: 2, disabled: "(out of stock)" menu.choice name: "large", value: 3 end # => # What size? (Press ↑/↓ arrow to move and Enter to select) # ‣ small # ✘ medium (out of stock) # large ``` or in a more compact way: ```ruby prompt.select("What size?") do |menu| menu.choice "small", 1 menu.choice "medium", 2, disabled: "(out of stock)" menu.choice "large", 3 end ``` #### 2.6.1.1 `:disabled` The `:disabled` key indicates to display a choice as currently unavailable to select. Disabled choices are displayed with a cross `✘` character next to them. If the choice is disabled, it cannot be selected. The value for the `:disabled` is used next to the choice to provide reason for excluding it from the selection menu. For example: ```ruby choices = [ {name: "small", value: 1}, {name: "medium", value: 2, disabled: "(out of stock)"}, {name: "large", value: 3} ] ``` ### 2.6.2 select For asking questions involving list of options use `select` method by passing the question and possible choices: ```ruby prompt.select("Choose your destiny?", %w(Scorpion Kano Jax)) # => # Choose your destiny? (Use ↑/↓ arrow keys, press Enter to select) # ‣ Scorpion # Kano # Jax ``` You can also provide options through DSL using the `choice` method for single entry and/or `choices` for more than one choice: ```ruby prompt.select("Choose your destiny?") do |menu| menu.choice "Scorpion" menu.choice "Kano" menu.choice "Jax" end # => # Choose your destiny? (Use ↑/↓ arrow keys, press Enter to select) # ‣ Scorpion # Kano # Jax ``` By default the choice name is used as return value, but you can provide your custom values including a `Proc` object: ```ruby prompt.select("Choose your destiny?") do |menu| menu.choice "Scorpion", 1 menu.choice "Kano", 2 menu.choice "Jax", -> { "Nice choice captain!" } end # => # Choose your destiny? (Use ↑/↓ arrow keys, press Enter to select) # ‣ Scorpion # Kano # Jax ``` If you wish you can also provide a simple hash to denote choice name and its value like so: ```ruby choices = {"Scorpion" => 1, "Kano" => 2, "Jax" => 3} prompt.select("Choose your destiny?", choices) ``` To mark particular answer as selected use `default` with either an index of the choice starting from `1` or a choice's name: ```ruby prompt.select("Choose your destiny?") do |menu| menu.default 3 # or menu.default "Jax" menu.choice "Scorpion", 1 menu.choice "Kano", 2 menu.choice "Jax", 3 end # => # Choose your destiny? (Use ↑/↓ arrow keys, press Enter to select) # Scorpion # Kano # ‣ Jax ``` #### 2.6.2.1 `:cycle` You can navigate the choices using the arrow keys or define your own key mappings (see [keyboard events](#212-keyboard-events). When reaching the top/bottom of the list, the selection does not cycle around by default. If you wish to enable cycling, you can pass `cycle: true` to `select` and `multi_select`: ```ruby prompt.select("Choose your destiny?", %w(Scorpion Kano Jax), cycle: true) # => # Choose your destiny? (Use ↑/↓ arrow keys, press Enter to select) # ‣ Scorpion # Kano # Jax ``` #### 2.6.2.2 `:enum` For ordered choices set `enum` to any delimiter String. In that way, you can use arrows keys and numbers (0-9) to select the item. ```ruby prompt.select("Choose your destiny?") do |menu| menu.enum "." menu.choice "Scorpion", 1 menu.choice "Kano", 2 menu.choice "Jax", 3 end # => # Choose your destiny? (Use ↑/↓ arrow or number (0-9) keys, press Enter to select) # 1. Scorpion # 2. Kano # ‣ 3. Jax ``` #### 2.6.2.3 `:help` You can configure help message with `:help` and when to display it with `:show_help` options. The help can be displayed on `start`, `never` or `always`: ```ruby choices = %w(Scorpion Kano Jax) prompt.select("Choose your destiny?", choices, help: "(Bash keyboard keys)", show_help: :always) # => # Choose your destiny? (Bash keyboard keys) # > Scorpion # Kano # Jax ``` #### 2.6.2.4 `:marker` You can configure active marker like so: ```ruby choices = %w(Scorpion Kano Jax) prompt.select("Choose your destiny?", choices, symbols: { marker: ">" }) # => # Choose your destiny? (Use ↑/↓ and ←/→ arrow keys, press Enter to select) # > Scorpion # Kano # Jax ``` #### 2.6.2.5 `:per_page` By default the menu is paginated if selection grows beyond `6` items. To change this setting use `:per_page` configuration. ```ruby letters = ("A".."Z").to_a prompt.select("Choose your letter?", letters, per_page: 4) # => # Which letter? (Use ↑/↓ and ←/→ arrow keys, press Enter to select) # ‣ A # B # C # D ``` You can also customise page navigation text using `:help` option: ```ruby letters = ("A".."Z").to_a prompt.select("Choose your letter?") do |menu| menu.per_page 4 menu.help "(Wiggle thy finger up/down and left/right to see more)" menu.choices letters end # => # Which letter? (Wiggle thy finger up/down and left/right to see more) # ‣ A # B # C # D ``` #### 2.6.2.6 `:disabled` To disable menu choice, use the `:disabled` key with a value that explains the reason for the choice being unavailable. For example, out of all warriors, the Goro is currently injured: ```ruby warriors = [ "Scorpion", "Kano", { name: "Goro", disabled: "(injury)" }, "Jax", "Kitana", "Raiden" ] ``` The disabled choice will be displayed with a cross `✘` character next to it and followed by an explanation: ```ruby prompt.select("Choose your destiny?", warriors) # => # Choose your destiny? (Use ↑/↓ arrow keys, press Enter to select) # ‣ Scorpion # Kano # ✘ Goro (injury) # Jax # Kitana # Raiden ``` #### 2.6.2.7 `:filter` To activate dynamic list searching on letter/number key presses use `:filter` option: ```ruby warriors = %w(Scorpion Kano Jax Kitana Raiden) prompt.select("Choose your destiny?", warriors, filter: true) # => # Choose your destiny? (Use ↑/↓ arrow keys, press Enter to select, and letter keys to filter) # ‣ Scorpion # Kano # Jax # Kitana # Raiden ``` After the user presses "k": ```ruby # => # Choose your destiny? (Filter: "k") # ‣ Kano # Kitana ``` After the user presses "ka": ```ruby # => # Choose your destiny? (Filter: "ka") # ‣ Kano ``` Filter characters can be deleted partially or entirely via, respectively, Backspace and Canc. If the user changes or deletes a filter, the choices previously selected remain selected. ### 2.6.3 multi_select For asking questions involving multiple selection list use `multi_select` method by passing the question and possible choices: ```ruby choices = %w(vodka beer wine whisky bourbon) prompt.multi_select("Select drinks?", choices) # => # # Select drinks? (Use ↑/↓ arrow keys, press Space to select and Enter to finish)" # ‣ ⬡ vodka # ⬡ beer # ⬡ wine # ⬡ whisky # ⬡ bourbon ``` As a return value, the `multi_select` will always return an array by default populated with the names of the choices. If you wish to return custom values for the available choices do: ```ruby choices = {vodka: 1, beer: 2, wine: 3, whisky: 4, bourbon: 5} prompt.multi_select("Select drinks?", choices) # Provided that vodka and beer have been selected, the function will return # => [1, 2] ``` Similar to `select` method, you can also provide options through DSL using the `choice` method for single entry and/or `choices` call for more than one choice: ```ruby prompt.multi_select("Select drinks?") do |menu| menu.choice :vodka, {score: 1} menu.choice :beer, 2 menu.choice :wine, 3 menu.choices whisky: 4, bourbon: 5 end ``` To mark choice(s) as selected use the `default` option with either index(s) of the choice(s) starting from `1` or choice name(s): ```ruby prompt.multi_select("Select drinks?") do |menu| menu.default 2, 5 # or menu.default :beer, :whisky menu.choice :vodka, {score: 10} menu.choice :beer, {score: 20} menu.choice :wine, {score: 30} menu.choice :whisky, {score: 40} menu.choice :bourbon, {score: 50} end # => # Select drinks? beer, bourbon # ⬡ vodka # ⬢ beer # ⬡ wine # ⬡ whisky # ‣ ⬢ bourbon ``` #### 2.6.3.1 `:cycle` Also like, `select`, the method takes an option `cycle` (which defaults to `false`), which lets you configure whether the selection should cycle around when reaching the top/bottom of the list when navigating: ```ruby prompt.multi_select("Select drinks?", %w(vodka beer wine), cycle: true) ``` #### 2.6.3.2 `:enum` Like `select`, for ordered choices set `enum` to any delimiter String. In that way, you can use arrows keys and numbers (0-9) to select the item. ```ruby prompt.multi_select("Select drinks?") do |menu| menu.enum ")" menu.choice :vodka, {score: 10} menu.choice :beer, {score: 20} menu.choice :wine, {score: 30} menu.choice :whisky, {score: 40} menu.choice :bourbon, {score: 50} end # => # Select drinks? beer, bourbon # ⬡ 1) vodka # ⬢ 2) beer # ⬡ 3) wine # ⬡ 4) whisky # ‣ ⬢ 5) bourbon ``` And when you press enter you will see the following selected: ```ruby # Select drinks? beer, bourbon # => [{score: 20}, {score: 50}] ``` #### 2.6.3.3 `:help` You can configure help message with `:help` and when to display it with `:show_help` options. The help can be displayed on `start`, `never` or `always`: ```ruby choices = {vodka: 1, beer: 2, wine: 3, whisky: 4, bourbon: 5} prompt.multi_select("Select drinks?", choices, help: "Press beer can against keyboard", show_help: :always) # => # Select drinks? (Press beer can against keyboard)" # ‣ ⬡ vodka # ⬡ beer # ⬡ wine # ⬡ whisky # ⬡ bourbon ``` #### 2.6.3.4 `:per_page` By default the menu is paginated if selection grows beyond `6` items. To change this setting use `:per_page` configuration. ```ruby letters = ("A".."Z").to_a prompt.multi_select("Choose your letter?", letters, per_page: 4) # => # Which letter? (Use ↑/↓ and ←/→ arrow keys, press Space to select and Enter to finish) # ‣ ⬡ A # ⬡ B # ⬡ C # ⬡ D ``` #### 2.6.3.5 `:disabled` To disable menu choice, use the `:disabled` key with a value that explains the reason for the choice being unavailable. For example, out of all drinks, the sake and beer are currently out of stock: ```ruby drinks = [ "bourbon", {name: "sake", disabled: "(out of stock)"}, "vodka", {name: "beer", disabled: "(out of stock)"}, "wine", "whisky" ] ``` The disabled choice will be displayed with a cross `✘` character next to it and followed by an explanation: ```ruby prompt.multi_select("Choose your favourite drink?", drinks) # => # Choose your favourite drink? (Use ↑/↓ arrow keys, press Space to select and Enter to finish) # ‣ ⬡ bourbon # ✘ sake (out of stock) # ⬡ vodka # ✘ beer (out of stock) # ⬡ wine # ⬡ whisky ``` #### 2.6.3.6 `:echo` To control whether the selected items are shown on the question header use the :echo option: ```ruby choices = %w(vodka beer wine whisky bourbon) prompt.multi_select("Select drinks?", choices, echo: false) # => # Select drinks? # ⬡ vodka # ⬢ 2) beer # ⬡ 3) wine # ⬡ 4) whisky # ‣ ⬢ 5) bourbon ``` #### 2.6.3.7 `:filter` To activate dynamic list filtering on letter/number typing, use the :filter option: ```ruby choices = %w(vodka beer wine whisky bourbon) prompt.multi_select("Select drinks?", choices, filter: true) # => # Select drinks? (Use ↑/↓ arrow keys, press Space to select and Enter to finish, and letter keys to filter) # ‣ ⬡ vodka # ⬡ beer # ⬡ wine # ⬡ whisky # ⬡ bourbon ``` After the user presses "w": ```ruby # Select drinks? (Filter: "w") # ‣ ⬡ wine # ⬡ whisky ``` Filter characters can be deleted partially or entirely via, respectively, Backspace and Canc. If the user changes or deletes a filter, the choices previously selected remain selected. The `filter` option is not compatible with `enum`. #### 2.6.3.8 `:min` To force the minimum number of choices an user must select, use the `:min` option: ```ruby choices = %w(vodka beer wine whisky bourbon) prompt.multi_select("Select drinks?", choices, min: 3) # => # Select drinks? (min. 3) vodka, beer # ⬢ vodka # ⬢ beer # ⬡ wine # ⬡ wiskey # ‣ ⬡ bourbon ``` #### 2.6.3.9 `:max` To limit the number of choices an user can select, use the `:max` option: ```ruby choices = %w(vodka beer wine whisky bourbon) prompt.multi_select("Select drinks?", choices, max: 3) # => # Select drinks? (max. 3) vodka, beer, whisky # ⬢ vodka # ⬢ beer # ⬡ wine # ⬢ whisky # ‣ ⬡ bourbon ``` ### 2.6.4 enum_select In order to ask for standard selection from indexed list you can use `enum_select` and pass question together with possible choices: ```ruby choices = %w(emacs nano vim) prompt.enum_select("Select an editor?", choices) # => # # Select an editor? # 1) nano # 2) vim # 3) emacs # Choose 1-3 [1]: ``` Similar to `select` and `multi_select`, you can provide question options through DSL using `choice` method and/or `choices` like so: ```ruby choices = %w(nano vim emacs) prompt.enum_select("Select an editor?") do |menu| menu.choice :nano, "/bin/nano" menu.choice :vim, "/usr/bin/vim" menu.choice :emacs, "/usr/bin/emacs" end # => # # Select an editor? # 1) nano # 2) vim # 3) emacs # Choose 1-3 [1]: # # Select an editor? /bin/nano ``` You can change the indexed numbers formatting by passing `enum` option. The `default` option lets you specify which choice to mark as selected by default. It accepts an index of the choice starting from `1` or a choice name: ```ruby choices = %w(nano vim emacs) prompt.enum_select("Select an editor?") do |menu| menu.default 2 # or menu.defualt "/usr/bin/vim" menu.enum "." menu.choice :nano, "/bin/nano" menu.choice :vim, "/usr/bin/vim" menu.choice :emacs, "/usr/bin/emacs" end # => # # Select an editor? # 1. nano # 2. vim # 3. emacs # Choose 1-3 [2]: # # Select an editor? /usr/bin/vim ``` #### 2.6.4.1 `:per_page` By default the menu is paginated if selection grows beyond `6` items. To change this setting use `:per_page` configuration. ```ruby letters = ("A".."Z").to_a prompt.enum_select("Choose your letter?", letters, per_page: 4) # => # Which letter? # 1) A # 2) B # 3) C # 4) D # Choose 1-26 [1]: # (Press tab/right or left to reveal more choices) ``` #### 2.6.4.2 `:disabled` To make a choice unavailable use the `:disabled` option and, if you wish, as value provide a reason: ```ruby choices = [ {name: "Emacs", disabled: "(not installed)"}, "Atom", "GNU nano", {name: "Notepad++", disabled: "(not installed)"}, "Sublime", "Vim" ] ``` The disabled choice will be displayed with a cross ✘ character next to it and followed by an explanation: ```ruby prompt.enum_select("Select an editor", choices) # => # Select an editor # ✘ 1) Emacs (not installed) # 2) Atom # 3) GNU nano # ✘ 4) Notepad++ (not installed) # 5) Sublime # 6) Vim # Choose 1-6 [2]: ``` ### 2.7 expand The `expand` provides a compact way to ask a question with many options. As first argument `expand` takes the message to display and as a second an array of choices. Compared to the `select`, `multi_select` and `enum_select`, the choices need to be objects that include `:key`, `:name` and `:value` keys. The `:key` must be a single character. The help choice is added automatically as the last option under the key `h`. ```ruby choices = [ { key: "y", name: "overwrite this file", value: :yes }, { key: "n", name: "do not overwrite this file", value: :no }, { key: "q", name: "quit; do not overwrite this file ", value: :quit } ] ``` The choices can also be provided through DSL using the `choice` method. The `:value` can be a primitive value or `Proc` instance that gets executed and whose value is used as returned type. For example: ```ruby prompt.expand("Overwrite Gemfile?") do |q| q.choice key: "y", name: "Overwrite" do :ok end q.choice key: "n", name: "Skip", value: :no q.choice key: "a", name: "Overwrite all", value: :all q.choice key: "d", name: "Show diff", value: :diff q.choice key: "q", name: "Quit", value: :quit end ``` The first element in the array of choices or provided via `choice` DSL will be the default choice, you can change that by passing `default` option. ```ruby prompt.expand("Overwrite Gemfile?", choices) # => # Overwrite Gemfile? (enter "h" for help) [y,n,q,h] ``` Each time user types an option a hint will be displayed: ```ruby # Overwrite Gemfile? (enter "h" for help) [y,n,a,d,q,h] y # >> overwrite this file ``` If user types `h` and presses enter, an expanded view will be shown which further allows to refine the choice: ```ruby # Overwrite Gemfile? # y - overwrite this file # n - do not overwrite this file # q - quit; do not overwrite this file # h - print help # Choice [y]: ``` Run `examples/expand.rb` to see the prompt in action. #### 2.7.1 `:auto_hint` To show hint by default use `:auto_hint` option: ```ruby prompt.expand("Overwrite Gemfile?", choices, auto_hint: true) # => # Overwrite Gemfile? (enter "h" for help) [y,n,q,h] # >> overwrite this file ``` ### 2.8 collect In order to collect more than one answer use `collect` method. Using the `key` you can describe the answers key name. All the methods for asking user input such as `ask`, `mask`, `select` can be directly invoked on the key. The key composition is very flexible by allowing nested keys. If you want the value to be automatically converted to required type use [convert](#221-convert). For example to gather some contact information do: ```ruby prompt.collect do key(:name).ask("Name?") key(:age).ask("Age?", convert: :int) key(:address) do key(:street).ask("Street?", required: true) key(:city).ask("City?") key(:zip).ask("Zip?", validate: /\A\d{3}\Z/) end end # => # {:name => "Piotr", :age => 30, :address => {:street => "Street", :city => "City", :zip => "123"}} ``` In order to collect _mutliple values_ for a given key in a loop, chain `values` onto the `key` desired: ```ruby result = prompt.collect do key(:name).ask("Name?") key(:age).ask("Age?", convert: :int) while prompt.yes?("continue?") key(:addresses).values do key(:street).ask("Street?", required: true) key(:city).ask("City?") key(:zip).ask("Zip?", validate: /\A\d{3}\Z/) end end end # => # { # :name => "Piotr", # :age => 30, # :addresses => [ # {:street => "Street", :city => "City", :zip => "123"}, # {:street => "Street", :city => "City", :zip => "234"} # ] # } ``` ### 2.9 suggest To suggest possible matches for the user input use `suggest` method like so: ```ruby prompt.suggest("sta", ["stage", "stash", "commit", "branch"]) # => # Did you mean one of these? # stage # stash ``` To customize query text presented pass `:single_text` and `:plural_text` options to respectively change the message when one match is found or many. ```ruby possible = %w(status stage stash commit branch blame) prompt.suggest("b", possible, indent: 4, single_text: "Perhaps you meant?") # => # Perhaps you meant? # blame ``` ### 2.10 slider If you'd rather not display all possible values in a vertical list, you may consider using `slider`. The slider provides easy visual way of picking a value marked by `●` symbol. For integers, you can set `:min`(defaults to 0), `:max` and `:step`(defaults to 1) options to configure slider range: ```ruby prompt.slider("Volume", min: 0, max: 100, step: 5) # => # Volume ──────────●────────── 50 # (Use ←/→ arrow keys, press Enter to select) ``` For everything else, you can provide an array of your desired choices: ```ruby prompt.slider("Letter", ('a'..'z').to_a) # => # Letter ────────────●───────────── m # (Use ←/→ arrow keys, press Enter to select) ``` By default the slider is configured to pick middle of the range as a start value, you can change this by using the `:default` option: ```ruby prompt.slider("Volume", max: 100, step: 5, default: 75) # => # Volume ───────────────●────── 75 # (Use ←/→ arrow keys, press Enter to select) ``` You can also select the default value by name: ```ruby prompt.slider("Letter", ('a'..'z').to_a, default: 'q') # => # Letter ──────────────────●─────── q # (Use ←/→ arrow keys, press Enter to select) ``` You can also change the default slider formatting using the `:format`. The value must contain the `:slider` token to show current value and any `sprintf` compatible flag for number display, in our case `%d`: ```ruby prompt.slider("Volume", max: 100, step: 5, default: 75, format: "|:slider| %d%%") # => # Volume |───────────────●──────| 75% # (Use ←/→ arrow keys, press Enter to select) ``` You can also specify slider range with decimal numbers. For example, to have a step of `0.5` and display each value with a single decimal place use `%f` as format: ```ruby prompt.slider("Volume", max: 10, step: 0.5, default: 5, format: "|:slider| %.1f") # => # Volume |───────────────●──────| 7.5 # (Use ←/→ arrow keys, press Enter to select) ``` You can alternatively provide a proc/lambda to customize your formatting even further: ```ruby slider_format = -> (slider, value) { "|#{slider}| #{value.zero? ? "muted" : "%.1f"}" % value } prompt.slider("Volume", max: 10, step: 0.5, default: 0, format: slider_format) # => # Volume |●─────────────────────| muted # (Use ←/→ arrow keys, press Enter to select) ``` If you wish to change the slider handle and the slider range display use `:symbols` option: ```ruby prompt.slider("Volume", max: 100, step: 5, default: 75, symbols: {bullet: "x", line: "_"}) # => # Volume _______________x______ 75% # (Use ←/→ arrow keys, press Enter to select) ``` You can configure help message with `:help` and when to display with `:show_help` options. The help can be displayed on `start`, `never` or `always`: ```ruby prompt.slider("Volume", max: 10, default: 7, help: "(Move arrows left and right to set value)", show_help: :always) # => # Volume ───────────────●────── 7 # (Move arrows left and right to set value) ``` Slider can be configured through DSL as well: ```ruby prompt.slider("What size?") do |range| range.max 100 range.step 5 range.default 75 range.format "|:slider| %d%%" end # => # Volume |───────────────●──────| 75% # (Use ←/→ arrow keys, press Enter to select) ``` ```ruby prompt.slider("What letter?") do |range| range.choices ('a'..'z').to_a range.format "|:slider| %s" range.default 'q' end # => # What letter? |──────────────────●───────| q # (Use ←/→ arrow keys, press Enter to select) ``` ### 2.11 say To simply print message out to standard output use `say` like so: ```ruby prompt.say(...) ``` The `say` method also accepts option `:color` which supports all the colors provided by [pastel](https://github.com/piotrmurach/pastel#3-supported-colors) **TTY::Prompt** provides more specific versions of `say` method to better express intention behind the message such as `ok`, `warn` and `error`. #### 2.11.1 ok Print message(s) in green do: ```ruby prompt.ok(...) ``` #### 2.12.2 warn Print message(s) in yellow do: ```ruby prompt.warn(...) ``` #### 2.11.3 error Print message(s) in red do: ```ruby prompt.error(...) ``` #### 2.12 keyboard events All the prompt types, when a key is pressed, fire key press events. You can subscribe to listen to this events by calling `on` with type of event name. ```ruby prompt.on(:keypress) { |event| ... } ``` The event object is yielded to a block whenever particular event fires. The event has `key` and `value` methods. Further, the `key` responds to following messages: * `name` - the name of the event such as :up, :down, letter or digit * `meta` - true if event is non-standard key associated * `shift` - true if shift has been pressed with the key * `ctrl` - true if ctrl has been pressed with the key For example, to add vim like key navigation to `select` prompt one would do the following: ```ruby prompt.on(:keypress) do |event| if event.value == "j" prompt.trigger(:keydown) end if event.value == "k" prompt.trigger(:keyup) end end ``` You can subscribe to more than one event: ```ruby prompt.on(:keypress) { |key| ... } .on(:keydown) { |key| ... } ``` The available events are: * `:keypress` * `:keydown` * `:keyup` * `:keyleft` * `:keyright` * `:keynum` * `:keytab` * `:keyenter` * `:keyreturn` * `:keyspace` * `:keyescape` * `:keydelete` * `:keybackspace` ## 3 settings ### 3.1. `:symbols` Many prompts use symbols to display information. You can overwrite the default symbols for all the prompts using the `:symbols` key and hash of symbol names as value: ```ruby prompt = TTY::Prompt.new(symbols: {marker: ">"}) ``` The following symbols can be overwritten: | Symbols | Unicode | ASCII | | ----------- |:-------:|:-----:| | tick | `✓` | `√` | | cross | `✘` | `x` | | marker | `‣` | `>` | | dot | `•` | `.` | | bullet | `●` | `O` | | line | `─` | `-` | | radio_on | `⬢` | `(*)` | | radio_off | `⬡` | `( )` | | arrow_up | `↑` | `↑` | | arrow_down | `↓` | `↓` | | arrow_left | `←` | `←` | | arrow_right| `→` | `→` | ### 3.2 `:active_color` All prompt types support `:active_color` option. By default it's set to `:green` value. The `select`, `multi_select`, `enum_select` and `expand` prompts use the active color to highlight the currently selected choice. The answer provided by the user is also highlighted with the active color. This `:active_color` as value accepts either a color symbol or callable object. For example, to change all prompts active color to `:cyan` do: ```ruby prompt = TTY::Prompt.new(active_color: :cyan) ``` You could also use `pastel`: ```ruby notice = Pastel.new.cyan.on_blue.detach prompt = TTY::Prompt.new(active_color: notice) ```` Or use coloring of your own choice: ``` prompt = TTY::Prompt.new(active_color: ->(str) { my-color-gem(str) }) ``` This option can be applied either globally for all prompts or individually: ```ruby prompt.select("What size?", %w(Large Medium Small), active_color: :cyan) ``` Please [see pastel](https://github.com/piotrmurach/pastel#3-supported-colors) for all supported colors. ### 3.3 `:enable_color` If you wish to disable coloring for a prompt simply pass `:enable_color` option ```ruby prompt = TTY::Prompt.new(enable_color: false) ``` ### 3.4 `:help_color` The `:help_color` option is used to customize the display color for all the help text. By default it's set to `:bright_black` value. Prompts such as `select`, `multi_select`, `expand` support `:help_color`. This option can be applied either globally for all prompts or individually. The `:help_color` option as value accepts either a color symbol or callable object. For example, to change all prompts help color to `:cyan` do: ```ruby prompt = TTY::Prompt.new(help_color: :cyan) ``` You could also use `pastel`: ```ruby notice = Pastel.new.cyan.on_blue.detach prompt = TTY::Prompt.new(help_color: notice) ```` Or use coloring of your own choice: ```ruby prompt = TTY::Prompt.new(help_color: ->(str) { my-color-gem(str) }) ``` Or configure `:help_color` for an individual prompt: ```ruby prompt.select("What size?", %w(Large Medium Small), help_color: :cyan) ``` Please [see pastel](https://github.com/piotrmurach/pastel#3-supported-colors) for all supported colors. ### 3.5 `:interrupt` By default `InputInterrupt` error will be raised when the user hits the interrupt key(Control-C). However, you can customise this behaviour by passing the `:interrupt` option. The available options are: * `:signal` - sends interrupt signal * `:exit` - exits with status code * `:noop` - skips handler * custom proc For example, to send interrupt signal do: ```ruby prompt = TTY::Prompt.new(interrupt: :signal) ``` ### 3.6 `:prefix` You can prefix each question asked using the `:prefix` option. This option can be applied either globally for all prompts or individual for each one: ```ruby prompt = TTY::Prompt.new(prefix: "[?] ") ``` ### 3.7 `:quiet` Prompts such as `select`, `multi_select`, `expand`, `slider` support `:quiet` which is used to disable re-echoing of the question and answer after selection is done. This option can be applied either globally for all prompts or individually. ```ruby # global prompt = TTY::Prompt.new(quiet: true) # single prompt prompt.select("What is your favorite color?", %w(blue yellow orange)) ```` ### 3.8 `:track_history` The prompts that accept line input such as `multiline` or `ask` provide history buffer that tracks all the lines entered during `TTY::Prompt.new` interactions. The history buffer provides previous or next lines when user presses up/down arrows respectively. However, if you wish to disable this behaviour use `:track_history` option like so: ```ruby prompt = TTY::Prompt.new(track_history: false) ``` ## Contributing 1. Fork it ( https://github.com/piotrmurach/tty-prompt/fork ) 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create a new Pull Request This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct. ## Copyright Copyright (c) 2015 Piotr Murach. See LICENSE for further details. tty-prompt-0.23.1/Rakefile 0000664 0000000 0000000 00000000217 14036620446 0015406 0 ustar 00root root 0000000 0000000 require "bundler/gem_tasks" FileList['tasks/**/*.rake'].each(&method(:import)) desc 'Run all specs' task ci: %w[ spec ] task default: :spec tty-prompt-0.23.1/appveyor.yml 0000664 0000000 0000000 00000001366 14036620446 0016337 0 ustar 00root root 0000000 0000000 --- skip_commits: files: - "benchmarks/**" - "examples/**" - "*.md" install: - set PATH=C:\Ruby%ruby_version%\bin;%PATH% - gem install bundler -v '< 2.0' - bundle config mirror.https://rubygems.org http://rubygems.org - bundle install before_test: - ruby -v - gem -v - bundle -v build: off test_script: - bundle exec rake ci environment: matrix: - ruby_version: "200" - ruby_version: "200-x64" - ruby_version: "21" - ruby_version: "21-x64" - ruby_version: "22" - ruby_version: "22-x64" - ruby_version: "23" - ruby_version: "23-x64" - ruby_version: "24" - ruby_version: "24-x64" - ruby_version: "25" - ruby_version: "25-x64" - ruby_version: "26" - ruby_version: "26-x64" tty-prompt-0.23.1/assets/ 0000775 0000000 0000000 00000000000 14036620446 0015243 5 ustar 00root root 0000000 0000000 tty-prompt-0.23.1/assets/demo.gif 0000664 0000000 0000000 00001700346 14036620446 0016671 0 ustar 00root root 0000000 0000000 GIF89a2 1 # 9I c l( y) $ ?x39 #-Q3f.M)G:( !g9"$(")7#$ %((;-(=S**2*D,P-[0?U0C70O1!1+/12119G2d@6L94/9?V9[;?I;b=F?>;>B^IBkJD_EREgF81HDGKKUL@5NF>NcQN[NbONJPZfQhRSVSjYSkSpUWYU|dUeVVS\PD^YV_i`_b`m`reG:egmesjgVIhihi\Vi_`jZJj]KkOHkntltmtnkjnlnn~prmqurh_s~uruvzvv~~xzsl|zv~~}~61ǽ¾ƿúƻɻ!NETSCAPE2.0 ! , 2 H*\ȰÇ#JHŋ3jȱǏ ?b8"ɓ(S\ɲ˗0c48̛8sɳϟ/kJѣH*U(tӧPJJU`ӪXjʵī^ÊKOfӪ]˶WnʝKw,ںx۳),ȁ +^̸1-ѢˈO̙ ǠCmjꉿ'f@)E;,m5g ЂI=@KX/F&|vE 0(@@BV/c C|͋ 8Ѷ+6akn_ si]w}'ނ%TsL SA-`j6i&rX ̀_:` - <0 X$@n`XfyS( @3bA llN>첣@ aN*1O<k tb$3ʀ3.p.l#ϟ¬ Cl5 ;tMSn' #fUy a @ >PA ى09t,@$`C /#" #3`#3) S+2J0ӋH P, 3--*ebUNrw-t =C 6Ak@8(P3ـp.L36۰C)@#i${B`x D38q)3HsBt q0@iT|g;r ( 13N6O0 O*3t6,32C L2`3"8s65%pCE= 3IP"V|1zܥb+Dv .K:;0Msd,p\g,A jG}ͰF<1) A;|q|6&@721j5^ h0`cGC1!&Rأ hF p[: d!IL!$XF<@U ƻpp A={Blh #HGpj}w@Cmp3É(8v!fCְf2AHhQ] ^`5U9` dA4Ʊ=f2'x@y 1FLƉ'Ll]@i @EF 24lj`L 76o#P`^@z@g0J.da :%y G>R:=It;e鞩