https://github.com/shime/terminal-menu
Retro ANSI terminal menu.
https://github.com/shime/terminal-menu
Last synced: 9 months ago
JSON representation
Retro ANSI terminal menu.
- Host: GitHub
- URL: https://github.com/shime/terminal-menu
- Owner: shime
- License: mit
- Created: 2016-08-28T08:17:28.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2018-01-29T10:16:00.000Z (over 8 years ago)
- Last Synced: 2025-05-18T01:36:10.515Z (about 1 year ago)
- Language: Ruby
- Homepage:
- Size: 26.4 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Terminal Menu
[](https://travis-ci.org/twobucks/terminal-menu)
Retro ANSI terminal menu.

## Install
```
gem install terminal-menu
```
## Example
```ruby
require 'terminal-menu'
menu = TerminalMenu.new(title: 'Rick Astley - Never Gonna Give You Up',
description: '',
width: 40,
fg: 'white',
bg: 'red') do |selected|
puts "you have selected: #{selected}"
menu.quit
end
menu.add('Never gonna give you up') do |selected|
puts "first option selected"
end
menu.add('Never gonna let you down') do |selected|
puts "second option selected"
end
menu.add('Never gonna run around and desert you') do |selected|
puts "third option selected"
end
menu.show
```
# API
```ruby
# Initializes new TerminalMenu instance.
#
# block - Optional block that will get called with label once some option
# is selected
#
# Options:
#
# title - The title of this menu (default: '')
# description - The description of this menu (default: '')
# width - The width of this menu in chars (default: 80)
# fg - Foreground color of this menu (default: 'white')
# bg - Background color of this menu (default: 'black')
# stdin - Input IO instance (default: STDIN)
# stdout - Output IO instance (default: STDOUT)
menu = TerminalMenu.new(title: '', description: '', width: 80,
fg: 'white', bg: 'black',
stdin: STDIN, stdout: STDOUT){|selected| block }
# Adds a new item to menu options.
#
# label - Label for this menu option.
# blk - Optional block that will be called once this option is selected.
menu.add(label, &blk)
# Starts read-eval-print loop.
menu.show
# Quits this menu.
menu.quit
```
## Thanks
To [@substack](https://github.com/substack) for creating [terminal-menu](https://github.com/substack/terminal-menu) for Node.
## License
MIT