summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorAbinoam Praxedes Marques Jr <abinoam@gmail.com>2015-10-07 22:17:35 -0300
committerAbinoam Praxedes Marques Jr <abinoam@gmail.com>2015-10-09 23:33:48 -0300
commit2e737f1a0995f7b4ef22c6b29990afa377e453a1 (patch)
tree12479a9076821491d563c9b9abcf8c202dcce433 /README.md
parent40811c904bfba33fe6c58aba4b8ec98c0d1f505c (diff)
downloadhighline-2e737f1a0995f7b4ef22c6b29990afa377e453a1.tar.gz
Use markdown language hint for syntax highlighting
Diffstat (limited to 'README.md')
-rw-r--r--README.md43
1 files changed, 28 insertions, 15 deletions
diff --git a/README.md b/README.md
index b109560..708b79d 100644
--- a/README.md
+++ b/README.md
@@ -29,42 +29,55 @@ See HighLine and HighLine::Question for documentation.
Start hacking in your code with HighLine with:
- require 'highline/import'
+```ruby
+require 'highline/import'
+```
Examples
--------
Basic usage:
- ask("Company? ") { |q| q.default = "none" }
+```ruby
+ask("Company? ") { |q| q.default = "none" }
+```
Validation:
- ask("Age? ", Integer) { |q| q.in = 0..105 }
- ask("Name? (last, first) ") { |q| q.validate = /\A\w+, ?\w+\Z/ }
+```ruby
+ask("Age? ", Integer) { |q| q.in = 0..105 }
+ask("Name? (last, first) ") { |q| q.validate = /\A\w+, ?\w+\Z/ }
+```
Type conversion for answers:
- ask("Birthday? ", Date)
- ask("Interests? (comma sep list) ", lambda { |str| str.split(/,\s*/) })
+```ruby
+ask("Birthday? ", Date)
+ask("Interests? (comma sep list) ", lambda { |str| str.split(/,\s*/) })
+```
Reading passwords:
- ask("Enter your password: ") { |q| q.echo = false }
- ask("Enter your password: ") { |q| q.echo = "x" }
+```ruby
+ask("Enter your password: ") { |q| q.echo = false }
+ask("Enter your password: ") { |q| q.echo = "x" }
+```
ERb based output (with HighLine's ANSI color tools):
- say("This should be <%= color('bold', BOLD) %>!")
+```ruby
+say("This should be <%= color('bold', BOLD) %>!")
+```
Menus:
- choose do |menu|
- menu.prompt = "Please choose your favorite programming language? "
-
- menu.choice(:ruby) { say("Good choice!") }
- menu.choices(:python, :perl) { say("Not from around here, are you?") }
- end
+```ruby
+choose do |menu|
+ menu.prompt = "Please choose your favorite programming language? "
+ menu.choice(:ruby) { say("Good choice!") }
+ menu.choices(:python, :perl) { say("Not from around here, are you?") }
+end
+```
For more examples see the examples/ directory of this project.