Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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.