prompt 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -160,8 +160,8 @@ a parameter, to further limit the completions.
160
160
 
161
161
  ```ruby
162
162
  param :username do |starting_with|
163
- # slow DB query
164
- User.where("username LIKE '?%'", starting_with).map(&:username)
163
+ # Query database for usernames that start with the partially-typed word
164
+ User.where("username LIKE '?%'", starting_with).pluck(:username)
165
165
  end
166
166
  ```
167
167
 
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'prompt'
4
+ extend Prompt::DSL
5
+
6
+ desc "List all your tasks"
7
+ command "list" do
8
+ if @tasks.empty?
9
+ puts "Nothing to do!"
10
+ else
11
+ @tasks.each_with_index do |task, i|
12
+ puts "#{i}: #{task}"
13
+ end
14
+ end
15
+ end
16
+
17
+ desc "Add a task to to the bottom of the list"
18
+ command "add :task" do |task|
19
+ @tasks << task
20
+ end
21
+
22
+ desc "'high' or 'low'"
23
+ param :priority do
24
+ %w(high low)
25
+ end
26
+
27
+ desc "Add a task to to the top or bottom of the list"
28
+ command "add :task :priority" do |task, priority|
29
+ if priority == "high"
30
+ @tasks.insert 0, task
31
+ else
32
+ @tasks << task
33
+ end
34
+ end
35
+
36
+ desc "Task number"
37
+ param :num do
38
+ puts "here"
39
+ (0...@tasks.size).to_a
40
+ end
41
+
42
+ desc "Delete a task"
43
+ command "del :num" do |num|
44
+ task = @tasks.delete_at num.to_i
45
+ puts "deleted #{task}" if task
46
+ end
47
+
48
+ desc "Delete all tasks"
49
+ command "clear" do
50
+ count = clear
51
+ puts "deleted #{count} items"
52
+ end
53
+
54
+ def clear
55
+ old_size = @tasks.size
56
+ @tasks = []
57
+ old_size
58
+ end
59
+
60
+ @tasks = []
61
+
62
+ Prompt::Console.start
@@ -1,5 +1,5 @@
1
1
  module Prompt
2
- VERSION = "1.2.1"
2
+ VERSION = "1.2.2"
3
3
 
4
4
  class << self
5
5
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prompt
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,10 +9,10 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-10 00:00:00.000000000 Z
12
+ date: 2013-01-21 00:00:00.000000000 Z
13
13
  dependencies: []
14
- description: Prompt makes it easy to build slick command-line applications with tab
15
- completion, command history, and built-in help
14
+ description: Prompt makes it easy to build slick CLIs with tab completion, command
15
+ history, and built-in help
16
16
  email: mike@sticknet.net
17
17
  executables: []
18
18
  extensions: []
@@ -40,9 +40,9 @@ files:
40
40
  - spec/prompt/console_spec.rb
41
41
  - spec/spec_helper.rb
42
42
  - examples/file_manager
43
- - examples/guess.rb
44
43
  - examples/mud
45
- homepage: http://github.com/mudynamics/prompt
44
+ - examples/todo_list
45
+ homepage: http://github.com/msmith/prompt
46
46
  licenses: []
47
47
  post_install_message:
48
48
  rdoc_options: []
@@ -65,5 +65,5 @@ rubyforge_project:
65
65
  rubygems_version: 1.8.23
66
66
  signing_key:
67
67
  specification_version: 3
68
- summary: A micro framework that makes it easy to build slick command-line applications
68
+ summary: A micro framework that makes it easy to build slick CLIs
69
69
  test_files: []
@@ -1,12 +0,0 @@
1
- require 'prompt'
2
- extend Prompt::DSL
3
-
4
- param :num do
5
- (1..10).to_a
6
- end
7
-
8
- command "guess :num" do |num|
9
- puts "you guessed #{num}"
10
- end
11
-
12
- Prompt::Console.start