alfred_git 0.5.3 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/bin/console CHANGED
@@ -1,14 +1,14 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "alfred_git"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "alfred_git"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup CHANGED
@@ -1,8 +1,8 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/lib/alfred_git.rb CHANGED
@@ -1,372 +1,368 @@
1
- require 'YAML'
2
- require 'rainbow'
3
- require 'fileutils'
4
-
5
- require_relative './alfred_git/version'
6
-
7
- module AlfredGit
8
- class AlfredGit
9
- include AlfredGitVersion
10
-
11
- def initialize
12
- set_app_directory
13
- # If there's just one, it's the current version.
14
- restore_settings if Dir.glob("#{@app_directory.chomp("/alfred_git-#{VERSION}")}/alfred_git*").length > 1 &&
15
- !(File.exists?("#{@app_directory}/lib/config.yaml"))
16
- config unless File.exists?("#{@app_directory}/lib/config.yaml")
17
- config_yaml = YAML.load_file("#{@app_directory}/lib/config.yaml")
18
-
19
- @repo_locations = config_yaml['repos']
20
- @name = config_yaml['name'].nil? ? 'Wayne' : config_yaml['name']
21
- @gender = config_yaml['gender'].nil? ? 'sir' : config_yaml['gender']
22
- end
23
-
24
- def alfred(arguments)
25
- @arguments = arguments
26
- alfred_command
27
- command = command_to_git_command
28
- repos = repos_string_to_array
29
-
30
- repos.each do |repo|
31
- lines_pretty_print Rainbow("Repo #{repo}:").yellow
32
- bash(@repo_locations[repo], command)
33
-
34
- single_space
35
- end
36
- end
37
-
38
- def alfred_command
39
- case @arguments[0]
40
- when nil, ''
41
- lines_pretty_print Rainbow("I need a command to run, Master #{@name}.").red
42
-
43
- abort
44
- when 'list_repo', 'list_repos', 'listrepo', 'listrepos'
45
- lines_pretty_print "Here are your repos and their locations, Master #{@name}:"
46
-
47
- single_space
48
-
49
- list_repos_and_locations
50
-
51
- single_space
52
-
53
- abort
54
- when 'add_repo', 'addrepo'
55
- if second_argument_missing?
56
- lines_pretty_print Rainbow("I need a repo name for the new repo, Master #{@name}.").red
57
-
58
- abort
59
- end
60
-
61
- add_repo
62
-
63
- abort
64
- when 'delete_repo', 'deleterepo', 'deletrepo'
65
- if second_argument_missing?
66
- lines_pretty_print Rainbow("I need a repo name to know which repo I'm deleting, Master #{@name}.").red
67
-
68
- abort
69
- end
70
-
71
- delete_repo
72
-
73
- abort
74
- end
75
- end
76
-
77
- def list_repos_and_locations
78
- @repo_locations.each do |repo, location|
79
- lines_pretty_print Rainbow("#{repo}").yellow + ": #{location}"
80
- end
81
- end
82
-
83
- def add_repo
84
- repo_name = @arguments[1]
85
-
86
- single_space
87
-
88
- lines_pretty_print "I can add the #{repo_name} repo straight away, #{@gender}. Where is that repository? "\
89
- 'Please paste the full path.'
90
-
91
- repo_path = STDIN.gets.strip!
92
-
93
- single_space
94
-
95
- config_yaml = YAML.load_file("#{@app_directory}/lib/config.yaml")
96
- config_file = File.open("#{@app_directory}/lib/config.yaml", 'w')
97
-
98
- config_yaml['repos'][repo_name] = repo_path
99
- YAML.dump(config_yaml, config_file)
100
-
101
- lines_pretty_print Rainbow("I've added that repository successfully, #{@gender}!").green
102
-
103
- single_space
104
- end
105
-
106
- def delete_repo
107
- repo_name = @arguments[1]
108
-
109
- single_space
110
-
111
- config_yaml = YAML.load_file("#{@app_directory}/lib/config.yaml")
112
- config_file = File.open("#{@app_directory}/lib/config.yaml", 'w')
113
-
114
- if config_yaml['repos'].keys.include?(repo_name)
115
- config_yaml['repos'].delete(repo_name)
116
-
117
- lines_pretty_print Rainbow("I've deleted that repository successfully, #{@gender}!").green
118
- else
119
- lines_pretty_print Rainbow("Sorry, #{@gender}, that is not a repository that is currently in my list. "\
120
- 'If you\'d *really* like to delete it, please add it first using the '\
121
- '\'add_repo\' command.').red
122
- end
123
-
124
- YAML.dump(config_yaml, config_file)
125
-
126
- single_space
127
- end
128
-
129
- def command_to_git_command
130
- command = ''
131
-
132
- case @arguments[0]
133
- when 'pull'
134
- command = 'git pull'
135
-
136
- delete_arguments(1)
137
- when 'push'
138
- command = 'git push'
139
-
140
- delete_arguments(1)
141
- when 'checkout'
142
- if second_argument_missing?
143
- lines_pretty_print Rainbow('I need a branch name to execute the \'checkout\' command, Master '\
144
- "#{@name}.").red
145
-
146
- abort
147
- end
148
-
149
- command = "git checkout #{@arguments[1]}"
150
-
151
- delete_arguments(2)
152
- when 'commit'
153
- if second_argument_missing?
154
- lines_pretty_print Rainbow('I need a commit message to execute the \'commit\' command, Master '\
155
- "#{@name}.").red
156
-
157
- abort
158
- end
159
-
160
- command = %Q[git commit -m "#{@arguments[1]}"]
161
-
162
- delete_arguments(2)
163
- when 'status'
164
- command = 'git status'
165
-
166
- delete_arguments(1)
167
- when 'branches', 'branch'
168
- command = 'git rev-parse --abbrev-ref HEAD'
169
-
170
- delete_arguments(1)
171
- when 'woa', 'wielder_of_anor', 'wielderofanor'
172
- if second_argument_missing?
173
- lines_pretty_print Rainbow("I need a commit message to pass to wielder_of_anor, Master #{@name}.").red
174
-
175
- abort
176
- end
177
-
178
- if @arguments[2] && @arguments[2] == '1'
179
- command = %Q[wielder_of_anor "#{@arguments[1]}" 1]
180
-
181
- delete_arguments(3)
182
- else
183
- command = %Q[wielder_of_anor "#{@arguments[1]}"]
184
-
185
- delete_arguments(2)
186
- end
187
- else
188
- command = @arguments[0] # Allow users to send any command to all repos.
189
-
190
- delete_arguments(1)
191
- end
192
-
193
- command
194
- end
195
-
196
- # All other arguments are deleted before we get here, so this should be just the repo list.
197
- def repos_string_to_array
198
- if @arguments[0].nil?|| @arguments[0] == ''
199
- lines_pretty_print Rainbow("I need at least one repository to work with, Master #{@name}.").red
200
-
201
- abort
202
- elsif @arguments[0] == 'all'
203
- return @repo_locations.keys
204
- else
205
- return @arguments
206
- end
207
- end
208
-
209
- def config
210
- config_file = File.open("#{@app_directory}/lib/config.yaml", 'w')
211
-
212
- lines_pretty_print 'Good evening, Master Wayne. Thank you for utilizing my abilities. Please enter your '\
213
- 'last name if you\'d like me to address you as something other than Wayne.'
214
- lines_pretty_print Rainbow('(Just hit enter to stick with \'Master Wayne\'.)').yellow
215
-
216
- name = STDIN.gets.strip!
217
-
218
- name = name == '' ? 'Wayne' : name
219
-
220
- single_space
221
-
222
- lines_pretty_print 'Thank you, sir. You...are a sir, correct?'
223
-
224
- gender_set = false
225
-
226
- until gender_set
227
- gender = STDIN.gets.strip!
228
-
229
- single_space
230
-
231
- if gender == 'yes' || gender == 'y'
232
- gender = 'sir'
233
- gender_set = true
234
- elsif gender == 'no' || gender == 'n'
235
- gender = 'madam'
236
- gender_set = true
237
- else
238
- lines_pretty_print "Very funny, Master #{name}."
239
- lines_pretty_print Rainbow('Please input either \'yes\' or \'no\'.').yellow
240
- end
241
- end
242
-
243
- lines_pretty_print "Yes, of course. My apologies. Please do not take offense, #{gender}. I am, after "\
244
- 'all, a simple computer program. Don\'t have eyes, you see. Now, let\'s gather a '\
245
- 'list of the code repositories you work with, shall we?'
246
-
247
- single_space
248
-
249
- repos = {}
250
- done = false
251
- repo_count = 0
252
-
253
- until done do
254
- first = repo_count > 0 ? 'next' : 'first'
255
-
256
- lines_pretty_print "What is the 'friendly' name you'd like to give your #{first} repository? This is the "\
257
- 'name you will type when sending me commands. If you are done adding them, please '\
258
- 'enter \'x211\' as your input instead.'
259
-
260
- repo_name = STDIN.gets.strip!
261
-
262
- if repo_name == 'x211'
263
- done = true
264
- single_space
265
- next
266
- end
267
-
268
- single_space
269
-
270
- lines_pretty_print "Thank you, #{gender}. Now, where is that repository? Please paste the full path."
271
-
272
- repo_path = STDIN.gets.strip!
273
-
274
- single_space
275
-
276
- repos[repo_name] = repo_path
277
- repo_count += 1
278
-
279
- lines_pretty_print Rainbow("I've added that repository successfully, #{gender}!").green
280
-
281
- single_space
282
- end
283
-
284
- YAML.dump({ 'name' => name, 'gender' => gender, 'repos' => repos }, config_file)
285
- config_file.close
286
-
287
- lines_pretty_print "Thank you for helping me set things up, Master #{name}. Feel free to run me whenever "\
288
- 'you need.'
289
-
290
- abort
291
- end
292
-
293
- # Attempt to restore settings from previous version.
294
- def restore_settings
295
- lines_pretty_print 'I see that you have a previous alfred_git installation on this machine.'
296
- lines_pretty_print Rainbow('Would you like to restore its settings?').yellow
297
-
298
- answered = false
299
-
300
- until answered
301
- answer = STDIN.gets.strip!
302
-
303
- single_space
304
-
305
- if answer == 'yes' || answer == 'y' || answer == 'no' || answer == 'n'
306
- answered = true
307
- else
308
- lines_pretty_print 'You\'re hilarious. Really.'
309
- lines_pretty_print Rainbow('Please input either \'yes\' or \'no\'.').yellow
310
- end
311
- end
312
-
313
- return if answer == 'no' || answer == 'n'
314
-
315
- lines_pretty_print 'One moment, please.'
316
-
317
- single_space
318
-
319
- all_gems = Dir.glob("#{@app_directory.chomp("/alfred_git-#{VERSION}")}/alfred_git*")
320
-
321
- # glob orders things in the array alphabetically, so the second-to-last one in the array is the
322
- # most recent version that is not the current version.
323
- previous_config_file = "#{all_gems[-2]}/lib/config.yaml"
324
- FileUtils.copy_file(previous_config_file, "#{@app_directory}/lib/config.yaml")
325
-
326
- lines_pretty_print 'Done! Please run me again when you\'re ready.'
327
-
328
- abort
329
- end
330
-
331
- def second_argument_missing?
332
- @arguments[1].nil? || @arguments[1] == ''
333
- end
334
-
335
- def delete_arguments(number_to_delete)
336
- (1..number_to_delete).each do
337
- # Deleting the first one each time because the array shifts left when one is deleted.
338
- @arguments.delete_at(0)
339
- end
340
- end
341
-
342
- def bash(directory, command)
343
- # Dir.chdir ensures all bash commands are being run from the correct
344
- # directory.
345
- Dir.chdir(directory) { system "#{command}" }
346
- end
347
-
348
- def set_app_directory
349
- @app_directory = File.expand_path(File.dirname(__FILE__)).chomp('/lib')
350
- end
351
-
352
- def lines_pretty_print(string)
353
- lines = string.scan(/\S.{0,70}\S(?=\s|$)|\S+/)
354
-
355
- lines.each { |line| puts line }
356
- end
357
-
358
- def single_space
359
- puts ''
360
- end
361
-
362
- def double_space
363
- puts "\n\n"
364
- end
365
-
366
- def surround_by_double_space(string)
367
- double_space
368
- lines_pretty_print(string)
369
- double_space
370
- end
371
- end
1
+ require 'YAML'
2
+ require 'rainbow'
3
+ require 'fileutils'
4
+ require 'find'
5
+ require 'iamsellek_cl_helper'
6
+
7
+ require_relative './alfred_git/version'
8
+
9
+ module AlfredGit
10
+ class AlfredGit
11
+ include AlfredGitVersion
12
+ include IamsellekClHelper
13
+
14
+ def initialize
15
+ set_app_directory
16
+
17
+ # If there's just one, it's the current version.
18
+ restore_settings('alfred_git', VERSION) if
19
+ Dir.glob("#{@app_directory.chomp("/alfred_git-#{VERSION}")}/alfred_git*").length > 1 &&
20
+ !(File.exists?("#{@app_directory}/lib/config.yaml"))
21
+
22
+ config unless File.exists?("#{@app_directory}/lib/config.yaml")
23
+ config_yaml = YAML.load_file("#{@app_directory}/lib/config.yaml")
24
+
25
+ @repo_locations = config_yaml['repos']
26
+ @name = config_yaml['name'].nil? ? 'Wayne' : config_yaml['name']
27
+ @gender = config_yaml['gender'].nil? ? 'sir' : config_yaml['gender']
28
+ end
29
+
30
+ def alfred(arguments)
31
+ @arguments = arguments
32
+ alfred_command
33
+ command = command_to_git_command
34
+ repos = repos_string_to_array
35
+
36
+ repos.each do |repo|
37
+ lines_pretty_print Rainbow("Repo #{repo}:").yellow
38
+ bash(@repo_locations[repo], command)
39
+
40
+ single_space
41
+ end
42
+ end
43
+
44
+ def alfred_command
45
+ case @arguments[0]
46
+ when nil, ''
47
+ lines_pretty_print Rainbow("I need a command to run, Master #{@name}.").red
48
+
49
+ abort
50
+ when 'list_repo', 'list_repos', 'listrepo', 'listrepos'
51
+ lines_pretty_print "Here are your repos and their locations, Master #{@name}:"
52
+
53
+ single_space
54
+
55
+ list_repos_and_locations
56
+
57
+ single_space
58
+
59
+ abort
60
+ when 'add_repo', 'addrepo', 'ar'
61
+ if second_argument_missing?(@arguments)
62
+ lines_pretty_print Rainbow("I need a repo name for the new repo, Master #{@name}.").red
63
+
64
+ abort
65
+ end
66
+
67
+ add_repo
68
+
69
+ abort
70
+ when 'delete_repo', 'deleterepo', 'deletrepo', 'dr'
71
+ if second_argument_missing?(@arguments)
72
+ lines_pretty_print Rainbow("I need a repo name to know which repo I'm deleting, Master #{@name}.").red
73
+
74
+ abort
75
+ end
76
+
77
+ delete_repo
78
+
79
+ abort
80
+ when 'repo_add_directory', 'rad'
81
+
82
+ if second_argument_missing?(@arguments)
83
+ lines_pretty_print Rainbow("I need a directory path to know which repos to add, Master #{@name}.").red
84
+
85
+ abort
86
+ end
87
+
88
+ repo_add_directory
89
+
90
+ abort
91
+ end
92
+ end
93
+
94
+ def list_repos_and_locations
95
+ @repo_locations.each do |repo, location|
96
+ lines_pretty_print Rainbow("#{repo}:").yellow + " #{location}"
97
+ end
98
+ end
99
+
100
+ def add_repo
101
+ repo_name = @arguments[1]
102
+
103
+ single_space
104
+
105
+ lines_pretty_print "I can add the #{repo_name} repo straight away, #{@gender}. Where is that repository? "\
106
+ 'Please paste the full path.'
107
+
108
+ repo_path = STDIN.gets.strip!
109
+
110
+ single_space
111
+
112
+ config_yaml = YAML.load_file("#{@app_directory}/lib/config.yaml")
113
+ config_file = File.open("#{@app_directory}/lib/config.yaml", 'w')
114
+
115
+ config_yaml['repos'][repo_name] = repo_path
116
+ YAML.dump(config_yaml, config_file)
117
+
118
+ lines_pretty_print Rainbow("I've added that repository successfully, #{@gender}!").green
119
+
120
+ single_space
121
+ end
122
+
123
+ def delete_repo
124
+ repo_name = @arguments[1]
125
+
126
+ single_space
127
+
128
+ config_yaml = YAML.load_file("#{@app_directory}/lib/config.yaml")
129
+ config_file = File.open("#{@app_directory}/lib/config.yaml", 'w')
130
+
131
+ if repo_name == 'all'
132
+ config_yaml['repos'] = {}
133
+ lines_pretty_print Rainbow("I've deleted all repositories successfully, #{@gender}!").green
134
+ elsif config_yaml['repos'].keys.include?(repo_name)
135
+ config_yaml['repos'].delete(repo_name)
136
+
137
+ lines_pretty_print Rainbow("I've deleted that repository successfully, #{@gender}!").green
138
+ else
139
+ lines_pretty_print Rainbow("Sorry, #{@gender}, that is not a repository that is currently in my list. "\
140
+ 'If you\'d *really* like to delete it, please add it first using the '\
141
+ '\'add_repo\' command.').red
142
+ end
143
+
144
+ YAML.dump(config_yaml, config_file)
145
+
146
+ single_space
147
+ end
148
+
149
+ def repo_add_directory
150
+ single_space
151
+
152
+ if @arguments[1] == '.'
153
+ rootDir = Dir.pwd
154
+ else
155
+ rootDir = @arguments[1]
156
+ end
157
+
158
+ repo_paths = []
159
+
160
+ Find.find(rootDir) do |path|
161
+ already_found_repo = false
162
+ puts path
163
+
164
+ repo_paths.each do |repo_path|
165
+ already_found_repo = path.include?(repo_path)
166
+ end
167
+
168
+ next if already_found_repo
169
+
170
+ if path =~ /.*\.git$/ && !already_found_repo
171
+ repo_paths << path[0...-5]
172
+ end
173
+ end
174
+
175
+ config_yaml = YAML.load_file("#{@app_directory}/lib/config.yaml")
176
+ config_file = File.open("#{@app_directory}/lib/config.yaml", 'w')
177
+
178
+ lines_pretty_print Rainbow("I've added the following repositories successfully, #{@gender}").green
179
+
180
+ single_space
181
+
182
+ repo_paths.each do |path|
183
+ repo = path.split('/').last
184
+ location = rootDir
185
+
186
+ if config_yaml['repos'][repo] == nil
187
+ config_yaml['repos'][repo] = path
188
+ lines_pretty_print Rainbow(repo + ":").yellow + path
189
+ else
190
+ altPath = path
191
+ altPath.slice! rootDir + "/"
192
+ config_yaml['repos'][altPath] = rootDir + "/" + path
193
+ lines_pretty_print Rainbow(altPath + ":").yellow + rootDir + "/" + path
194
+ end
195
+ end
196
+
197
+ YAML.dump(config_yaml, config_file)
198
+ end
199
+
200
+ def command_to_git_command
201
+ command = ''
202
+
203
+ case @arguments[0]
204
+ when 'pull'
205
+ command = 'git pull'
206
+
207
+ delete_arguments(@arguments, 1)
208
+ when 'push'
209
+ command = 'git push'
210
+
211
+ delete_arguments(@arguments, 1)
212
+ when 'checkout'
213
+ if second_argument_missing?(@arguments)
214
+ lines_pretty_print Rainbow('I need a branch name to execute the \'checkout\' command, Master '\
215
+ "#{@name}.").red
216
+
217
+ abort
218
+ end
219
+
220
+ command = "git checkout #{@arguments[1]}"
221
+
222
+ delete_arguments(@arguments, 2)
223
+ when 'commit'
224
+ if second_argument_missing?(@arguments)
225
+ lines_pretty_print Rainbow('I need a commit message to execute the \'commit\' command, Master '\
226
+ "#{@name}.").red
227
+
228
+ abort
229
+ end
230
+
231
+ command = %Q[git commit -m "#{@arguments[1]}"]
232
+
233
+ delete_arguments(@arguments, 2)
234
+ when 'status'
235
+ command = 'git status'
236
+
237
+ delete_arguments(@arguments, 1)
238
+ when 'branches', 'branch'
239
+ command = 'git rev-parse --abbrev-ref HEAD'
240
+
241
+ delete_arguments(@arguments, 1)
242
+ when 'woa', 'wielder_of_anor', 'wielderofanor'
243
+ if second_argument_missing?(@arguments)
244
+ lines_pretty_print Rainbow("I need a commit message to pass to wielder_of_anor, Master #{@name}.").red
245
+
246
+ abort
247
+ end
248
+
249
+ if @arguments[2] && @arguments[2] == '1'
250
+ command = %Q[wielder_of_anor "#{@arguments[1]}" 1]
251
+
252
+ delete_arguments(@arguments, 3)
253
+ else
254
+ command = %Q[wielder_of_anor "#{@arguments[1]}"]
255
+
256
+ delete_arguments(@arguments, 2)
257
+ end
258
+ else
259
+ command = @arguments[0] # Allow users to send any command to all repos.
260
+
261
+ delete_arguments(@arguments, 1)
262
+ end
263
+
264
+ command
265
+ end
266
+
267
+ # All other arguments are deleted before we get here, so this should be just the repo list.
268
+ def repos_string_to_array
269
+ if @arguments[0].nil?|| @arguments[0] == ''
270
+ lines_pretty_print Rainbow("I need at least one repository to work with, Master #{@name}.").red
271
+
272
+ abort
273
+ elsif @arguments[0] == 'all'
274
+ return @repo_locations.keys
275
+ else
276
+ return @arguments
277
+ end
278
+ end
279
+
280
+ def config
281
+ config_file = File.open("#{@app_directory}/lib/config.yaml", 'w')
282
+
283
+ lines_pretty_print 'Good evening, Master Wayne. Thank you for utilizing my abilities. Please enter your '\
284
+ 'last name if you\'d like me to address you as something other than Wayne.'
285
+ lines_pretty_print Rainbow('(Just hit enter to stick with \'Master Wayne\'.)').yellow
286
+
287
+ name = STDIN.gets.strip!
288
+
289
+ name = name == '' ? 'Wayne' : name
290
+
291
+ single_space
292
+
293
+ lines_pretty_print 'Thank you, sir. You...are a sir, correct?'
294
+
295
+ gender_set = false
296
+
297
+ until gender_set
298
+ gender = STDIN.gets.strip!
299
+
300
+ single_space
301
+
302
+ if gender == 'yes' || gender == 'y'
303
+ gender = 'sir'
304
+ gender_set = true
305
+ elsif gender == 'no' || gender == 'n'
306
+ gender = 'madam'
307
+ gender_set = true
308
+ else
309
+ lines_pretty_print "Very funny, Master #{name}."
310
+ lines_pretty_print Rainbow('Please input either \'yes\' or \'no\'.').yellow
311
+ end
312
+ end
313
+
314
+ lines_pretty_print "Yes, of course. My apologies. Please do not take offense, #{gender}. I am, after "\
315
+ 'all, a simple computer program. Don\'t have eyes, you see. Now, let\'s gather a '\
316
+ 'list of the code repositories you work with, shall we?'
317
+
318
+ single_space
319
+
320
+ repos = {}
321
+ done = false
322
+ repo_count = 0
323
+
324
+ until done do
325
+ first = repo_count > 0 ? 'next' : 'first'
326
+
327
+ lines_pretty_print "What is the 'friendly' name you'd like to give your #{first} repository? This is the "\
328
+ 'name you will type when sending me commands. If you are done adding them, please '\
329
+ 'enter \'x211\' as your input instead.'
330
+
331
+ repo_name = STDIN.gets.strip!
332
+
333
+ if repo_name == 'x211'
334
+ done = true
335
+ single_space
336
+ next
337
+ end
338
+
339
+ single_space
340
+
341
+ lines_pretty_print "Thank you, #{gender}. Now, where is that repository? Please paste the full path."
342
+
343
+ repo_path = STDIN.gets.strip!
344
+
345
+ single_space
346
+
347
+ repos[repo_name] = repo_path
348
+ repo_count += 1
349
+
350
+ lines_pretty_print Rainbow("I've added that repository successfully, #{gender}!").green
351
+
352
+ single_space
353
+ end
354
+
355
+ YAML.dump({ 'name' => name, 'gender' => gender, 'repos' => repos }, config_file)
356
+ config_file.close
357
+
358
+ lines_pretty_print "Thank you for helping me set things up, Master #{name}. Feel free to run me whenever "\
359
+ 'you need.'
360
+
361
+ abort
362
+ end
363
+
364
+ def set_app_directory
365
+ @app_directory = File.expand_path(File.dirname(__FILE__)).chomp('/lib')
366
+ end
367
+ end
372
368
  end