madCLIbs 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0c3ce55fec8d9b38d33c8eb9d4d716281c1b6bc2
4
- data.tar.gz: 75dfe916d9f51d70a2c521aff89c1360772422ac
3
+ metadata.gz: d6e4489abd1410baba0ed65e21de82b707ec9148
4
+ data.tar.gz: 61fb3e613fc43515672c173379e1264c197a39a6
5
5
  SHA512:
6
- metadata.gz: ae10344a49778297444e83391b9e681e0d95e1dd2eb37efcb0b2c016c01bceaa1bb1313716b8fae0649736051e8c0a49b8f975e67eff65fdd19106253e10f4cf
7
- data.tar.gz: 476a18157930971186915a5c57a548adb4d21740c89bfaeaa2509375e6148d0f3425864a8fc2d88b3786deb93e081b308cc3e5d9478de283d66b273f5a0909e5
6
+ metadata.gz: 38c35fbd1232947ae63bc5eafc6867de5c7f78bb6e14760b2115cac1869c4421f7a5dc178ef8c72895b7f4d03b8a5b62782ce8d620d3db98e634d6975b80fd83
7
+ data.tar.gz: 7841306381833dca8616ba18e4645407396155f585cc2eccfe34a6195daf6b7a1b96249cfc46f48932abb5c60c7996b92233051666909cb8ffb0681c4a1ad88d
data/README.md CHANGED
@@ -1,12 +1,13 @@
1
1
  # MadCLI</tt>bs:<br> User-Friendly Fill-in-the-Blank(s) UX for your Terminal Application
2
+ [![Gem Version](https://badge.fury.io/rb/madCLIbs.svg)](http://badge.fury.io/rb/madCLIbs) [![Code Climate](https://codeclimate.com/github/donaldguy/madCLIbs/badges/gpa.svg)](https://codeclimate.com/github/donaldguy/madCLIbs) [![Dependency Status](https://gemnasium.com/donaldguy/madCLIbs.svg)](https://gemnasium.com/donaldguy/madCLIbs)
3
+
2
4
 
3
5
  Seeks to mimic the familiar UX of HTML5 form elements, with
4
6
  [placeholders](http://diveintohtml5.info/forms.html#placeholder),
5
7
  in the terminal.
6
8
 
7
- Allows a program to present a line with one or more "blanks" which can be edited and moved between
8
- at will (with tab or up & down arrow keys). On new line, returns the values of the blanks (treating
9
- placeholders as a default values)
9
+ Allows a program to present a line with one or more "blanks" which can be edited and cycled between
10
+ at will (with `Tab` & `Shift-Tab` or :arrow_up: & :arrow_down: keys). On `Return`/new line, returns the values of the blanks (treating placeholders as a default values if no editing occured)
10
11
 
11
12
  The name is supposed to be Mad Libs with a CLI in it, but you might also
12
13
  reasonably call it "Mad CLI BS" :smile:
@@ -17,7 +18,11 @@ pretty useful for things like [Dramaturg](https://github.com/donaldguy/dramaturg
17
18
 
18
19
  ## Usage
19
20
 
20
- See [examples](https://github.com/donaldguy/madCLIbs/tree/master/examples)
21
+ See [examples](https://github.com/donaldguy/madCLIbs/tree/master/examples) for example code
22
+
23
+ Here's a quick UX demo
24
+
25
+ ![Demo Gif](http://g.recordit.co/igWkgeP8wM.gif)
21
26
 
22
27
  ## Contributing
23
28
 
data/examples/basic.rb CHANGED
@@ -1,6 +1,14 @@
1
1
  require 'madCLIbs/import'
2
+ require 'term/ansicolor'
2
3
 
4
+ include Term::ANSIColor
3
5
 
4
- name, food = prompt("My name is", string(ENV['USER']), "and I like", string("chicken") )
6
+ name, food, side = prompt("My name is",
7
+ cyan(bold(string(ENV['USER']))),
8
+ "and I like",
9
+ bold(string("chicken")),
10
+ "with",
11
+ string(green("rice"))
12
+ )
5
13
 
6
- puts "Your name is #{name} and you like #{food}"
14
+ puts "Your name is #{name} and you like #{food} with #{side}"
@@ -26,9 +26,11 @@ class MadClibs
26
26
  end
27
27
 
28
28
  def save_and_remove_color(s)
29
+ @color_seed ||= '%{value}'
29
30
  colored = s
30
31
  uncolored = uncolor(s)
31
- @color_seed = colored.sub(%r'#{uncolored}', '%{value}')
32
+ new_color_seed = colored.sub(%r'#{uncolored}', '%{value}')
33
+ @color_seed = new_color_seed % {value: @color_seed}
32
34
  uncolored
33
35
  end
34
36
 
@@ -20,7 +20,7 @@ class MadClibs
20
20
  @valuebuff.left
21
21
  when "right"
22
22
  @valuebuff.right
23
- when /[\w\s]/
23
+ when /./
24
24
  @valuebuff << key
25
25
  else
26
26
  raise ArgumentError, "No handler for key '#{key}' (while focused on this blank)"
@@ -55,7 +55,7 @@ private
55
55
  def getc
56
56
  @last_char = @io.read_key
57
57
  case @last_char
58
- when "up"
58
+ when "up", "shift-tab"
59
59
  previous_blank!
60
60
  when "tab", "down"
61
61
  #if @active_blank.has_completions?
@@ -13,6 +13,7 @@ module IOHelper
13
13
 
14
14
  KEYS = {
15
15
  "\t" => "tab",
16
+ "\e[Z" => "shift-tab",
16
17
  "\r" => "return",
17
18
  "\n" => "linefeed",
18
19
  # "\e" => "escape",
@@ -1,3 +1,3 @@
1
1
  class MadClibs
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/madCLIbs.gemspec CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |spec|
13
13
  Seeks to mimic the familiar UX of HTML5 form elements, with placeholder attributes,
14
14
  in an ANSI-compatible terminal.
15
15
 
16
- Allows a program to present a line with one or more "blanks" which can be edited and moved between
17
- at will (with tab or up & down arrow keys). On new line, returns the values of the blanks (treating
16
+ Allows a program to present a line with one or more "blanks" which can be edited and cycled between
17
+ at will (with tab & shift-tab or up & down arrow keys). On new line, returns the values of the blanks (treating
18
18
  placeholders as a default values if no editing occured)
19
19
  EOS
20
20
  spec.homepage = "https://github.com/donaldguy/madCLIbs"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: madCLIbs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Donald Guy
@@ -42,8 +42,8 @@ description: |2
42
42
  Seeks to mimic the familiar UX of HTML5 form elements, with placeholder attributes,
43
43
  in an ANSI-compatible terminal.
44
44
 
45
- Allows a program to present a line with one or more "blanks" which can be edited and moved between
46
- at will (with tab or up & down arrow keys). On new line, returns the values of the blanks (treating
45
+ Allows a program to present a line with one or more "blanks" which can be edited and cycled between
46
+ at will (with tab & shift-tab or up & down arrow keys). On new line, returns the values of the blanks (treating
47
47
  placeholders as a default values if no editing occured)
48
48
  email:
49
49
  - fawkes@mit.edu