inquirer.rb 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile DELETED
@@ -1,2 +0,0 @@
1
- require "bundler/gem_tasks"
2
- task :default => :spec
@@ -1,211 +0,0 @@
1
- lib = File.expand_path('../../lib/', __FILE__)
2
- $:.unshift lib unless $:.include?(lib)
3
-
4
- require 'inquirer'
5
-
6
- questions = [
7
- {
8
- name: :invitation,
9
- type: :checkbox,
10
- message: 'Who should get invited?',
11
- choices: [
12
- {
13
- name: 'Karl',
14
- short: 'Kalli',
15
- },
16
- {
17
- name: 'Bert',
18
- value: "It's Bert!"
19
- },
20
- {
21
- name: 'Berta',
22
- value: :love
23
- },
24
- {
25
- name: 'Manfred',
26
- },
27
- {
28
- name: 'Holger',
29
- when: lambda { |_args| false }
30
- },
31
- {
32
- name: 'Tanja',
33
- when: true
34
- },
35
- ],
36
- },
37
- {
38
- name: :invitation_default,
39
- type: :checkbox,
40
- message: 'Who should get invited?',
41
- choices: [
42
- {
43
- name: 'Karl',
44
- short: 'Kalli',
45
- },
46
- {
47
- name: 'Bert',
48
- value: "It's Bert!"
49
- },
50
- {
51
- name: 'Berta',
52
- value: :love
53
- },
54
- {
55
- name: 'Manfred',
56
- },
57
- ],
58
- default: [
59
- "It's Bert!",
60
- :love,
61
- 'Manfred',
62
- ],
63
- },
64
- {
65
- name: :invitation_never,
66
- type: :checkbox,
67
- message: 'Who should get invited?',
68
- choices: [
69
- {
70
- name: 'Karl',
71
- short: 'Kalli',
72
- },
73
- {
74
- name: 'Bert',
75
- value: "It's Bert!"
76
- },
77
- {
78
- name: 'Berta',
79
- value: :love
80
- },
81
- {
82
- name: 'Manfred',
83
- },
84
- ],
85
- when: false,
86
- },
87
- {
88
- name: :invitation_never_lambda,
89
- type: :checkbox,
90
- message: 'Who should get invited?',
91
- choices: [
92
- {
93
- name: 'Karl',
94
- short: 'Kalli',
95
- },
96
- {
97
- name: 'Bert',
98
- value: "It's Bert!"
99
- },
100
- {
101
- name: 'Berta',
102
- value: :love
103
- },
104
- {
105
- name: 'Manfred',
106
- },
107
- ],
108
- when: lambda { |answers| true },
109
- },
110
- {
111
- name: :invitation_when_previous,
112
- type: :checkbox,
113
- message: 'Who should get invited?',
114
- choices: [
115
- {
116
- name: 'Karl',
117
- short: 'Kalli',
118
- },
119
- {
120
- name: 'Bert',
121
- value: "It's Bert!"
122
- },
123
- {
124
- name: 'Berta',
125
- value: :love
126
- },
127
- {
128
- name: 'Manfred',
129
- },
130
- ],
131
- when: lambda { |answers| answers[:invitation_default].size > 1 },
132
- },
133
- {
134
- name: :invitation_validate_size,
135
- type: :checkbox,
136
- message: 'Who should get invited?',
137
- choices: [
138
- {
139
- name: 'Karl',
140
- short: 'Kalli',
141
- },
142
- {
143
- name: 'Bert',
144
- value: "It's Bert!"
145
- },
146
- {
147
- name: 'Berta',
148
- value: :love
149
- },
150
- {
151
- name: 'Manfred',
152
- },
153
- ],
154
- validate: lambda { |answer| answer.size == 2 },
155
- },
156
- {
157
- name: :invitation_validate_tyler_message,
158
- type: :checkbox,
159
- message: 'Who should get invited?',
160
- choices: [
161
- {
162
- name: 'Karl',
163
- short: 'Kalli',
164
- },
165
- {
166
- name: 'Bert',
167
- value: "It's Bert!"
168
- },
169
- {
170
- name: 'Berta',
171
- value: :love
172
- },
173
- {
174
- name: 'Manfred',
175
- },
176
- ],
177
- validate: lambda { |answer|
178
- return true if answer.include? 'Tyler'
179
- 'Only Tyler!'
180
- },
181
- },
182
- {
183
- name: :invitation_filter_tyler,
184
- type: :checkbox,
185
- message: 'Who should get invited?',
186
- choices: [
187
- {
188
- name: 'Karl',
189
- short: 'Kalli',
190
- },
191
- {
192
- name: 'Bert',
193
- value: "It's Bert!"
194
- },
195
- {
196
- name: 'Berta',
197
- value: :love
198
- },
199
- {
200
- name: 'Manfred',
201
- },
202
- ],
203
- filter: lambda { |answer|
204
- ['Tyler']
205
- },
206
- },
207
- ]
208
-
209
- answers = Inquirer.prompt(questions)
210
-
211
- p answers
@@ -1,63 +0,0 @@
1
- lib = File.expand_path('../../lib/', __FILE__)
2
- $:.unshift lib unless $:.include?(lib)
3
-
4
- require 'inquirer'
5
-
6
- questions = [
7
- {
8
- name: :are_you_sure_type,
9
- type: :confirm,
10
- message: 'Are you sure?',
11
- },
12
- {
13
- name: :are_you_sure_default,
14
- type: :confirm,
15
- message: 'Are you sure?',
16
- default: true,
17
- },
18
- {
19
- name: :are_you_sure_never,
20
- type: :confirm,
21
- message: 'Are you sure?',
22
- when: false,
23
- },
24
- {
25
- name: :are_you_sure_never_lambda,
26
- type: :confirm,
27
- message: 'Are you sure?',
28
- when: lambda { |answers| true },
29
- },
30
- {
31
- name: :are_you_sure_when_previous,
32
- type: :confirm,
33
- message: 'Are you sure?',
34
- when: lambda { |answers| answers[:are_you_sure_default] },
35
- },
36
- {
37
- name: :are_you_sure_validate_true,
38
- type: :confirm,
39
- message: 'Are you sure?',
40
- validate: lambda { |answer| answer },
41
- },
42
- {
43
- name: :are_you_sure_validate_true_message,
44
- type: :confirm,
45
- message: 'Are you sure?',
46
- validate: lambda { |answer|
47
- return true if answer
48
- 'Only yes!'
49
- },
50
- },
51
- {
52
- name: :are_you_sure_filter_tyler,
53
- type: :confirm,
54
- message: 'Are you sure?',
55
- filter: lambda { |answer|
56
- 'Tyler'
57
- },
58
- },
59
- ]
60
-
61
- answers = Inquirer.prompt(questions)
62
-
63
- p answers
@@ -1,67 +0,0 @@
1
- lib = File.expand_path('../../lib/', __FILE__)
2
- $:.unshift lib unless $:.include?(lib)
3
-
4
- require 'inquirer'
5
-
6
- questions = [
7
- {
8
- name: :user_name_no_type,
9
- message: 'What is your name?',
10
- },
11
- {
12
- name: :user_name_type,
13
- type: :input,
14
- message: 'What is your name?',
15
- },
16
- {
17
- name: :user_name_default_tyler,
18
- type: :input,
19
- message: 'What is your name?',
20
- default: 'Tyler',
21
- },
22
- {
23
- name: :user_name_never,
24
- type: :input,
25
- message: 'What is your name?',
26
- when: false,
27
- },
28
- {
29
- name: :user_name_never_lambda,
30
- type: :input,
31
- message: 'What is your name?',
32
- when: lambda { |answers| true },
33
- },
34
- {
35
- name: :user_name_when_tyler,
36
- type: :input,
37
- message: 'What is your name?',
38
- when: lambda { |answers| answers[:user_name_default] == 'Tyler' },
39
- },
40
- {
41
- name: :user_name_validate_tyler,
42
- type: :input,
43
- message: 'What is your name?',
44
- validate: lambda { |answer| answer == 'Tyler' },
45
- },
46
- {
47
- name: :user_name_validate_tyler_message,
48
- type: :input,
49
- message: 'What is your name?',
50
- validate: lambda { |answer|
51
- return true if answer == 'Tyler'
52
- 'Only Tyler!'
53
- },
54
- },
55
- {
56
- name: :user_name_filter_tyler,
57
- type: :input,
58
- message: 'What is your name?',
59
- filter: lambda { |answer|
60
- 'Tyler'
61
- },
62
- },
63
- ]
64
-
65
- answers = Inquirer.prompt(questions)
66
-
67
- p answers
@@ -1,193 +0,0 @@
1
- lib = File.expand_path('../../lib/', __FILE__)
2
- $:.unshift lib unless $:.include?(lib)
3
-
4
- require 'inquirer'
5
-
6
- questions = [
7
- {
8
- name: :whos_best,
9
- type: :list,
10
- message: "Who's the best?",
11
- choices: [
12
- {
13
- name: 'Karl',
14
- short: 'Kalli',
15
- },
16
- {
17
- name: 'Bert',
18
- value: "It's Bert!"
19
- },
20
- {
21
- name: 'Berta',
22
- value: :love
23
- },
24
- {
25
- name: 'Manfred',
26
- },
27
- {
28
- name: 'Tyler',
29
- },
30
- {
31
- name: 'Rust',
32
- },
33
- {
34
- name: 'Marty',
35
- },
36
- {
37
- name: 'Steve',
38
- },
39
- {
40
- name: 'Holger',
41
- when: lambda { |_args| false }
42
- },
43
- {
44
- name: 'Tanja',
45
- when: true
46
- },
47
- ],
48
- },
49
- {
50
- name: :whos_best_default_value,
51
- type: :list,
52
- message: "Who's the best?",
53
- choices: [
54
- {
55
- name: 'Karl',
56
- short: 'Kalli',
57
- },
58
- {
59
- name: 'Bert',
60
- value: "It's Bert!"
61
- },
62
- {
63
- name: 'Berta',
64
- value: :love
65
- },
66
- {
67
- name: 'Manfred',
68
- },
69
- ],
70
- default: :love,
71
- },
72
- {
73
- name: :whos_best_default_index,
74
- type: :list,
75
- message: "Who's the best?",
76
- choices: [
77
- {
78
- name: 'Karl',
79
- short: 'Kalli',
80
- },
81
- {
82
- name: 'Bert',
83
- value: "It's Bert!"
84
- },
85
- {
86
- name: 'Berta',
87
- value: :love
88
- },
89
- {
90
- name: 'Manfred',
91
- },
92
- ],
93
- default: 2,
94
- },
95
- {
96
- name: :whos_best_never,
97
- type: :list,
98
- message: "Who's the best?",
99
- choices: [
100
- {
101
- name: 'Karl',
102
- short: 'Kalli',
103
- },
104
- {
105
- name: 'Bert',
106
- value: "It's Bert!"
107
- },
108
- {
109
- name: 'Berta',
110
- value: :love
111
- },
112
- {
113
- name: 'Manfred',
114
- },
115
- ],
116
- when: false,
117
- },
118
- {
119
- name: :whos_best_never_lambda,
120
- type: :list,
121
- message: "Who's the best?",
122
- choices: [
123
- {
124
- name: 'Karl',
125
- short: 'Kalli',
126
- },
127
- {
128
- name: 'Bert',
129
- value: "It's Bert!"
130
- },
131
- {
132
- name: 'Berta',
133
- value: :love
134
- },
135
- {
136
- name: 'Manfred',
137
- },
138
- ],
139
- when: lambda { |answers| true },
140
- },
141
- {
142
- name: :whos_best_when_previous,
143
- type: :list,
144
- message: "Who's the best?",
145
- choices: [
146
- {
147
- name: 'Karl',
148
- short: 'Kalli',
149
- },
150
- {
151
- name: 'Bert',
152
- value: "It's Bert!"
153
- },
154
- {
155
- name: 'Berta',
156
- value: :love
157
- },
158
- {
159
- name: 'Manfred',
160
- },
161
- ],
162
- when: lambda { |answers| answers[:whos_best_default_index].size > 1 },
163
- },
164
- {
165
- name: :whos_best_filter_tyler,
166
- type: :list,
167
- message: "Who's the best?",
168
- choices: [
169
- {
170
- name: 'Karl',
171
- short: 'Kalli',
172
- },
173
- {
174
- name: 'Bert',
175
- value: "It's Bert!"
176
- },
177
- {
178
- name: 'Berta',
179
- value: :love
180
- },
181
- {
182
- name: 'Manfred',
183
- },
184
- ],
185
- filter: lambda { |answer|
186
- ['Tyler']
187
- },
188
- },
189
- ]
190
-
191
- answers = Inquirer.prompt(questions)
192
-
193
- p answers