Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ddnexus/prompter
Makes your prompts easier to build and nicer to look.
https://github.com/ddnexus/prompter
Last synced: 5 days ago
JSON representation
Makes your prompts easier to build and nicer to look.
- Host: GitHub
- URL: https://github.com/ddnexus/prompter
- Owner: ddnexus
- License: mit
- Created: 2011-01-27T12:44:00.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2013-08-23T19:13:16.000Z (about 11 years ago)
- Last Synced: 2024-05-12T05:22:32.567Z (6 months ago)
- Language: Ruby
- Homepage:
- Size: 109 KB
- Stars: 8
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rdoc
- License: LICENSE
Awesome Lists containing this project
README
= Prompter
Makes your prompts easier to build and prettier to look.
== Synopsis
require 'prompter'
Prompter.new(:prefix => '** ') do |p|
p.say_notice 'You can avoid to extend your class with Prompter::Methods'
end# or
prompter = Prompter.new
# or you can also extend your modules with:
extend Prompter::Methods
self.prefix = ' '
say 'This part uses imported method from Prompter::Methods'ask 'Type some input:' do |input|
yes_no? "Do you want it or not?" do |yes|
if yes
say("#{input} is ok")
else
say_warning("#{input} may be dangerous")
end
end
end# or
name = ask('write your name:')
yes? "are you sure?" { do_something_if_yes }(see also the file "examples/wizard.rb")
== General Notes
Methods are callable directly on the Prompter class, on a Prompter object, included in your class as instance methods or class methods.
Some methods yield the block with the returned value, so you can use them as an easy way to construct hierarchical wizards.
The Prompter.dye_styles keys are passable as the :style option to the called method and will override the default styles,
They can also be redefined by setting the Prompter.dye_styles. (see the 'dye' gem for more info)== Documentation and Example
All the methods are yard-documented, and there is and 'example/wizard.rb' that could be useful.
== Copyright
Copyright (c) 2010-2012 Domizio Demichelis. See LICENSE for details.