ghedsh 1.1.40 → 2.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +12 -0
- data/.github/ISSUE_TEMPLATE.md +31 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +30 -0
- data/.gitignore +12 -1
- data/.rspec +3 -0
- data/CODE_OF_CONDUCT.md +46 -0
- data/Gemfile +5 -0
- data/LICENSE +165 -0
- data/README.md +6 -93
- data/Rakefile +3 -9
- data/bin/ghedsh +2 -1
- data/file_templates/add_members_template.json +12 -0
- data/file_templates/create_teams_template.json +19 -0
- data/file_templates/invite_outside_collabs.json +12 -0
- data/file_templates/remove_members_template.json +12 -0
- data/ghedsh.gemspec +3 -2
- data/lib/actions/orgs.rb +636 -842
- data/lib/actions/system.rb +212 -278
- data/lib/actions/teams.rb +15 -229
- data/lib/actions/user.rb +304 -12
- data/lib/commands.rb +465 -0
- data/lib/common.rb +15 -0
- data/lib/context.rb +42 -0
- data/lib/helpers.rb +147 -0
- data/lib/interface.rb +71 -733
- data/lib/plugin_loader.rb +43 -0
- data/lib/version.rb +1 -1
- data/spec/cli_spec.rb +30 -0
- data/spec/spec_helper.rb +106 -0
- metadata +38 -10
- data/docs/Javier-clemente-MemoriaTFG-ghedsh.pdf +0 -0
- data/lib/actions/help.rb +0 -357
- data/lib/actions/repo.rb +0 -832
- data/spec/spec.rb +0 -1
data/lib/interface.rb
CHANGED
@@ -1,764 +1,102 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'require_all'
|
3
|
-
require 'json'
|
4
1
|
require 'readline'
|
5
|
-
require 'octokit'
|
6
2
|
require 'optparse'
|
7
|
-
require 'actions/help'
|
8
|
-
require 'actions/orgs'
|
9
|
-
require 'actions/repo'
|
10
|
-
require 'actions/system'
|
11
|
-
require 'actions/teams'
|
12
|
-
require 'actions/user'
|
13
3
|
require 'version'
|
14
|
-
|
15
|
-
|
16
|
-
ORGS=2
|
17
|
-
USER_REPO=10
|
18
|
-
ORGS_REPO=3
|
19
|
-
TEAM=4
|
20
|
-
ASSIG=6
|
21
|
-
TEAM_REPO=5
|
4
|
+
require 'context'
|
5
|
+
require 'helpers'
|
22
6
|
|
23
7
|
class Interface
|
24
|
-
|
25
|
-
attr_accessor :config
|
26
|
-
attr_accessor :client
|
27
|
-
attr_accessor :deep
|
28
|
-
attr_accessor :memory
|
29
|
-
attr_reader :orgs_list,:repos_list, :teamlist, :orgs_repos, :teams_repos, :repo_path, :issues_list
|
30
|
-
|
31
|
-
def initialize
|
32
|
-
@sysbh=Sys.new()
|
33
|
-
@repos_list=[]; @orgs_repos=[]; @teams_repos=[]; @orgs_list=[]; @teamlist=[]
|
34
|
-
@repo_path=''
|
8
|
+
def initialize; end
|
35
9
|
|
36
|
-
|
10
|
+
def parse
|
11
|
+
options = { user: nil, token: nil, path: nil }
|
37
12
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
self.run(options[:path],options[:token],options[:user])
|
43
|
-
else
|
44
|
-
self.run("#{ENV['HOME']}/.ghedsh",options[:token],options[:user])
|
45
|
-
end
|
46
|
-
rescue SystemExit, Interrupt
|
47
|
-
raise
|
48
|
-
rescue Exception => e
|
49
|
-
puts "exit"
|
50
|
-
puts e
|
13
|
+
parser = OptionParser.new do |opts|
|
14
|
+
opts.banner = "Usage: ghedsh [options]\nWith no options it runs with default configuration. Configuration files are being set in #{ENV['HOME']}/.ghedsh\n"
|
15
|
+
opts.on('-t', '--token token', 'Provides a github access token by argument.') do |token|
|
16
|
+
options[:token] = token
|
51
17
|
end
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
def prompt()
|
56
|
-
case
|
57
|
-
when @deep == USER then return @config["User"]+"> "
|
58
|
-
when @deep == USER_REPO
|
59
|
-
if @repo_path!=""
|
60
|
-
@config["User"]+">"+ "\e[31m#{@config["Repo"]}\e[0m"+">"+"#{@repo_path}"+"> "
|
61
|
-
else
|
62
|
-
return @config["User"]+">"+ "\e[31m#{@config["Repo"]}\e[0m"+"> "
|
63
|
-
end
|
64
|
-
when @deep == ORGS then return @config["User"]+">"+ "\e[34m#{@config["Org"]}\e[0m"+"> "
|
65
|
-
when @deep == ASSIG then return @config["User"]+">"+ "\e[34m#{@config["Org"]}\e[0m"+">"+"\e[35m#{@config["Assig"]}\e[0m"+"> "
|
66
|
-
when @deep == TEAM then return @config["User"]+">"+"\e[34m#{@config["Org"]}\e[0m"+">"+"\e[32m#{@config["Team"]}\e[0m"+"> "
|
67
|
-
when @deep == TEAM_REPO
|
68
|
-
if @repo_path!=""
|
69
|
-
return @config["User"]+">"+"\e[34m#{@config["Org"]}\e[0m"+">"+"\e[32m#{@config["Team"]}\e[0m"+">"+"\e[31m#{@config["Repo"]}\e[0m"+">"+"#{@repo_path}"+"> "
|
70
|
-
else
|
71
|
-
return @config["User"]+">"+"\e[34m#{@config["Org"]}\e[0m"+">"+"\e[32m#{@config["Team"]}\e[0m"+">"+"\e[31m#{@config["Repo"]}\e[0m"+"> "
|
72
|
-
end
|
73
|
-
when @deep == ORGS_REPO then
|
74
|
-
if @repo_path!=""
|
75
|
-
return @config["User"]+">"+"\e[34m#{@config["Org"]}\e[0m"+">"+"\e[31m#{@config["Repo"]}\e[0m"+">"+"#{@repo_path}"+"> "
|
76
|
-
else
|
77
|
-
return @config["User"]+">"+"\e[34m#{@config["Org"]}\e[0m"+">"+"\e[31m#{@config["Repo"]}\e[0m"+"> "
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def help(opcd)
|
83
|
-
h=HelpM.new()
|
84
|
-
if opcd.size>1
|
85
|
-
h.context(opcd[1..opcd.size-1],@deep)
|
86
|
-
else
|
87
|
-
case
|
88
|
-
when @deep == USER
|
89
|
-
h.user()
|
90
|
-
when @deep == ORGS
|
91
|
-
h.org()
|
92
|
-
when @deep == ORGS_REPO
|
93
|
-
h.org_repo()
|
94
|
-
when @deep == USER_REPO
|
95
|
-
h.user_repo()
|
96
|
-
when @deep == TEAM
|
97
|
-
h.orgs_teams()
|
98
|
-
when @deep == TEAM_REPO
|
99
|
-
h.team_repo()
|
100
|
-
when @deep == ASSIG
|
101
|
-
h.asssig()
|
18
|
+
opts.on('-c', '--configpath path', 'Give your own path for GHEDSH configuration files') do |path|
|
19
|
+
options[:configpath] = path
|
102
20
|
end
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
#Go back to any level
|
107
|
-
def cdback(returnall)
|
108
|
-
if returnall!=true
|
109
|
-
case
|
110
|
-
when @deep == ORGS
|
111
|
-
@config["Org"]=nil
|
112
|
-
@deep=1
|
113
|
-
@orgs_repos=[]
|
114
|
-
when @deep == ORGS_REPO
|
115
|
-
if @repo_path==""
|
116
|
-
@config["Repo"]=nil
|
117
|
-
@deep=2
|
118
|
-
else
|
119
|
-
aux=@repo_path.split("/")
|
120
|
-
aux.pop
|
121
|
-
if aux.empty?
|
122
|
-
@repo_path=""
|
123
|
-
else
|
124
|
-
@repo_path=aux.join("/")
|
125
|
-
end
|
126
|
-
end
|
127
|
-
when @deep == USER_REPO
|
128
|
-
if @repo_path==""
|
129
|
-
@config["Repo"]=nil
|
130
|
-
@deep=1
|
131
|
-
else
|
132
|
-
aux=@repo_path.split("/")
|
133
|
-
aux.pop
|
134
|
-
if aux.empty?
|
135
|
-
@repo_path=""
|
136
|
-
else
|
137
|
-
@repo_path=aux.join("/")
|
138
|
-
end
|
139
|
-
end
|
140
|
-
when @deep == TEAM
|
141
|
-
@config["Team"]=nil
|
142
|
-
@config["TeamID"]=nil
|
143
|
-
@teams_repos=[]
|
144
|
-
@deep=ORGS
|
145
|
-
when @deep == ASSIG
|
146
|
-
@deep=ORGS
|
147
|
-
@config["Assig"]=nil
|
148
|
-
when @deep == TEAM_REPO
|
149
|
-
if @repo_path==""
|
150
|
-
@config["Repo"]=nil
|
151
|
-
@deep=TEAM
|
152
|
-
else
|
153
|
-
aux=@repo_path.split("/")
|
154
|
-
aux.pop
|
155
|
-
if aux.empty?
|
156
|
-
@repo_path=""
|
157
|
-
else
|
158
|
-
@repo_path=aux.join("/")
|
159
|
-
end
|
160
|
-
end
|
21
|
+
opts.on('-u', '--user user', 'Change your user from your users list') do |user|
|
22
|
+
options[:user] = user
|
161
23
|
end
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
@config["Team"]=nil
|
166
|
-
@config["TeamID"]=nil
|
167
|
-
@config["Assig"]=nil
|
168
|
-
@deep=1
|
169
|
-
@orgs_repos=[]; @teams_repos=[]
|
170
|
-
@repo_path="";
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
#Go to the path, depends with the scope
|
175
|
-
#if you are in user scope, first searchs Orgs then Repos, etc.
|
176
|
-
def cd(path)
|
177
|
-
if @deep==ORGS_REPO || @deep==USER_REPO || @deep==TEAM_REPO
|
178
|
-
self.cdrepo(path)
|
179
|
-
end
|
180
|
-
o=Organizations.new
|
181
|
-
path_split=path.split("/")
|
182
|
-
if path_split.size==1 ##cd con path simple
|
183
|
-
case
|
184
|
-
when @deep==USER
|
185
|
-
@orgs_list=o.read_orgs(@client)
|
186
|
-
aux=@orgs_list
|
187
|
-
if aux.one?{|aux| aux==path}
|
188
|
-
@config["Org"]=path
|
189
|
-
@teamlist=Teams.new.read_teamlist(@client,@config)
|
190
|
-
@sysbh.add_history_str(2,o.get_assigs(@client,@config,false))
|
191
|
-
@sysbh.add_history_str(1,@teamlist)
|
192
|
-
@deep=2
|
193
|
-
else
|
194
|
-
#puts "\nNo organization is available with that name"
|
195
|
-
self.set(path)
|
196
|
-
end
|
197
|
-
when @deep == ORGS
|
198
|
-
if @teamlist==[]
|
199
|
-
@teamlist=Teams.new.read_teamlist(@client,@config)
|
200
|
-
end
|
201
|
-
aux=@teamlist
|
202
|
-
|
203
|
-
if aux[path]!=nil
|
204
|
-
@config["Team"]=path
|
205
|
-
@config["TeamID"]=@teamlist[path]
|
206
|
-
@deep=TEAM
|
207
|
-
else
|
208
|
-
#puts "\nNo team is available with that name"
|
209
|
-
if cdassig(path)==false
|
210
|
-
self.set(path)
|
211
|
-
end
|
212
|
-
end
|
213
|
-
when @deep == TEAM
|
214
|
-
self.set(path)
|
24
|
+
opts.on('-v', '--version', 'Show the current version of GHEDSH') do
|
25
|
+
puts "GitHub Education Shell v#{Ghedsh::VERSION}"
|
26
|
+
exit
|
215
27
|
end
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
#set in the given path repository, first search in the list, then do the github query if list is empty
|
220
|
-
def set(path)
|
221
|
-
reposlist=Repositories.new()
|
222
|
-
|
223
|
-
case
|
224
|
-
when @deep==USER
|
225
|
-
@config["Repo"]=path
|
226
|
-
if @repos_list.empty? == false
|
227
|
-
reposlist=@repos_list
|
228
|
-
else
|
229
|
-
reposlist=reposlist.get_repos_list(@client,@config,@deep)
|
230
|
-
end
|
231
|
-
if reposlist.one?{|aux| aux==path}
|
232
|
-
@deep=USER_REPO
|
233
|
-
puts "Set in #{@config["User"]} repository: #{path}\n\n"
|
234
|
-
end
|
235
|
-
when @deep==ORGS
|
236
|
-
|
237
|
-
if @orgs_repos.empty? == false
|
238
|
-
reposlist=@orgs_repos
|
239
|
-
else
|
240
|
-
reposlist=reposlist.get_repos_list(@client,@config,@deep)
|
241
|
-
end
|
242
|
-
if reposlist.one?{|aux| aux==path}
|
243
|
-
@config["Repo"]=path
|
244
|
-
@deep=ORGS_REPO
|
245
|
-
puts "Set in #{@config["Org"]} repository: #{path}\n\n"
|
28
|
+
opts.on('-h', '--help', 'Displays Help') do
|
29
|
+
puts opts
|
30
|
+
exit
|
246
31
|
end
|
247
|
-
when @deep==TEAM
|
248
|
-
|
249
|
-
if @teams_repos.empty? == false
|
250
|
-
reposlist=@teams_repos
|
251
|
-
else
|
252
|
-
reposlist=reposlist.get_repos_list(@client,@config,@deep)
|
253
|
-
end
|
254
|
-
if reposlist.one?{|aux| aux==path}
|
255
|
-
@config["Repo"]=path
|
256
|
-
@deep=TEAM_REPO
|
257
|
-
puts "Set in #{@config["Team"]} repository: #{path}\n\n"
|
258
|
-
end
|
259
|
-
end
|
260
|
-
#if @deep==USER || @deep==ORGS || @deep==TEAM then puts "No repository is available with that name\n\n" end
|
261
|
-
if @deep==USER || @deep==ORGS || @deep==TEAM
|
262
|
-
puts "\nNo organization is available with that name"
|
263
|
-
puts "\nNo team is available with that name"
|
264
|
-
puts "No repository is available with that name\n\n"
|
265
|
-
end
|
266
|
-
end
|
267
|
-
|
268
|
-
def cdrepo(path)
|
269
|
-
r=Repositories.new()
|
270
|
-
list=[]
|
271
|
-
|
272
|
-
if @repo_path==""
|
273
|
-
newpath=path
|
274
|
-
else
|
275
|
-
newpath=@repo_path+"/"+path
|
276
|
-
end
|
277
|
-
list=r.get_files(@client,@config,newpath,false,@deep)
|
278
|
-
if list==nil
|
279
|
-
puts "Wrong path name"
|
280
|
-
else
|
281
|
-
@repo_path=newpath
|
282
32
|
end
|
283
|
-
end
|
284
33
|
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
puts "Set in #{@config["Org"]} assignment: #{path}\n\n"
|
291
|
-
@config["Assig"]=path
|
292
|
-
return true
|
293
|
-
else
|
294
|
-
puts "No assignment is available with that name"
|
295
|
-
return false
|
34
|
+
begin
|
35
|
+
parser.parse!
|
36
|
+
rescue StandardError
|
37
|
+
puts 'Argument error. Use ghedsh -h or ghedsh --help for more information about the usage of this program'
|
38
|
+
exit
|
296
39
|
end
|
40
|
+
options
|
297
41
|
end
|
298
42
|
|
299
|
-
def
|
300
|
-
|
301
|
-
|
302
|
-
@sysbh.add_history_str(2,Organizations.new.show_orgs(@client,@config))
|
303
|
-
when @deep==ORGS
|
304
|
-
Organizations.new.show_orgs(@client,@config)
|
305
|
-
end
|
306
|
-
end
|
43
|
+
def start
|
44
|
+
spinner = custom_spinner("Starting ghedsh CLI")
|
45
|
+
options = parse
|
307
46
|
|
308
|
-
|
309
|
-
case
|
310
|
-
when @deep==ORGS
|
311
|
-
@sysbh.add_history_str(2,Organizations.new.show_organization_members_bs(@client,@config))
|
312
|
-
when @deep==TEAM
|
313
|
-
@sysbh.add_history_str(2,Teams.new.show_team_members_bs(@client,@config))
|
314
|
-
end
|
315
|
-
end
|
47
|
+
trap('SIGINT') { puts; throw :ctrl_c }
|
316
48
|
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
if @repos_list.empty?
|
322
|
-
if all==false
|
323
|
-
list=repo.show_repos(@client,@config,USER,nil)
|
324
|
-
@sysbh.add_history_str(2,list)
|
325
|
-
@repos_list=list
|
326
|
-
else
|
327
|
-
list=repo.get_repos_list(@client,@config,USER)
|
328
|
-
@sysbh.add_history_str(2,list)
|
329
|
-
@repos_list=list
|
330
|
-
puts list
|
331
|
-
end
|
332
|
-
else
|
333
|
-
@sysbh.showcachelist(@repos_list,nil)
|
334
|
-
end
|
335
|
-
when @deep ==ORGS
|
336
|
-
if @orgs_repos.empty?
|
337
|
-
if all==false
|
338
|
-
list=repo.show_repos(@client,@config,ORGS,nil)
|
339
|
-
@sysbh.add_history_str(2,list)
|
340
|
-
@orgs_repos=list
|
341
|
-
else
|
342
|
-
#list=repo.show_repos(@client,@config,ORGS)
|
343
|
-
list=repo.get_repos_list(@client,@config,ORGS)
|
344
|
-
@sysbh.add_history_str(2,list)
|
345
|
-
@orgs_repos=list
|
346
|
-
puts list
|
347
|
-
end
|
348
|
-
else
|
349
|
-
@sysbh.showcachelist(@orgs_repos,nil)
|
350
|
-
end
|
351
|
-
when @deep==TEAM
|
352
|
-
if @teams_repos.empty?
|
353
|
-
if all==false
|
354
|
-
list=repo.show_repos(@client,@config,TEAM,nil)
|
355
|
-
@sysbh.add_history_str(2,list)
|
356
|
-
@teams_repos=list
|
357
|
-
else
|
358
|
-
list=repo.show_repos(@client,@config,TEAM)
|
359
|
-
@sysbh.add_history_str(2,list)
|
360
|
-
@repos_list=list
|
361
|
-
puts list
|
362
|
-
end
|
49
|
+
catch :ctrl_c do
|
50
|
+
begin
|
51
|
+
if options[:user].nil? && options[:token].nil? && !options[:path].nil?
|
52
|
+
@shell_enviroment = ShellContext.new(options[:user], options[:path], options[:token])
|
363
53
|
else
|
364
|
-
@
|
54
|
+
@shell_enviroment = ShellContext.new(options[:user], "#{ENV['HOME']}/.ghedsh", options[:token])
|
365
55
|
end
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
end
|
374
|
-
return list
|
375
|
-
end
|
376
|
-
|
377
|
-
def commits()
|
378
|
-
c=Repositories.new
|
379
|
-
if @deep==ORGS_REPO || @deep==USER_REPO || @deep==TEAM_REPO
|
380
|
-
c.show_commits(@client,@config,@deep)
|
381
|
-
end
|
382
|
-
print "\n"
|
383
|
-
end
|
384
|
-
|
385
|
-
def show_forks()
|
386
|
-
c=Repositories.new
|
387
|
-
if @deep==ORGS_REPO || @deep==USER_REPO || @deep==TEAM_REPO
|
388
|
-
c.show_forks(@client,@config,@deep)
|
389
|
-
end
|
390
|
-
end
|
391
|
-
|
392
|
-
def collaborators()
|
393
|
-
c=Repositories.new
|
394
|
-
if @deep==ORGS_REPO || @deep==USER_REPO || @deep==TEAM_REPO
|
395
|
-
c.show_collaborators(@client,@config,@deep)
|
396
|
-
end
|
397
|
-
end
|
398
|
-
|
399
|
-
#Main program
|
400
|
-
def run(config_path, argv_token,user)
|
401
|
-
ex=1
|
402
|
-
opscript=[]
|
403
|
-
@sysbh.write_initial_memory()
|
404
|
-
HelpM.new.welcome()
|
405
|
-
o=Organizations.new
|
406
|
-
t=Teams.new
|
407
|
-
r=Repositories.new
|
408
|
-
s=Sys.new
|
409
|
-
u=User.new
|
410
|
-
# orden de búsqueda: ~/.ghedsh.json ./ghedsh.json ENV["ghedsh"] --configpath path/to/file.json
|
411
|
-
|
412
|
-
#control de carga de parametros en el logueo de la aplicacion
|
413
|
-
if user!=nil
|
414
|
-
@config=s.load_config_user(config_path,user)
|
415
|
-
@client=s.client
|
416
|
-
if @config==nil
|
417
|
-
ex=0
|
56
|
+
spinner.stop
|
57
|
+
run
|
58
|
+
rescue SystemExit, Interrupt
|
59
|
+
raise
|
60
|
+
rescue Exception => e
|
61
|
+
puts 'exit'
|
62
|
+
puts e
|
418
63
|
end
|
419
|
-
@deep=USER
|
420
|
-
else
|
421
|
-
@config=s.load_config(config_path,argv_token) #retorna la configuracion ya guardada anteriormente
|
422
|
-
@client=s.client
|
423
|
-
@deep=s.return_deep(config_path)
|
424
|
-
#if @deep==ORGS then @teamlist=t.get_teamlist end #solucion a la carga de las ids de los equipos de trabajo
|
425
|
-
end
|
426
|
-
@sysbh.load_memory(config_path,@config)
|
427
|
-
#@deep=USER
|
428
|
-
if @client!=nil
|
429
|
-
@sysbh.add_history_str(2,Organizations.new.read_orgs(@client))
|
430
64
|
end
|
65
|
+
end
|
431
66
|
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
when op.include?("cd assig") && opcd[0]=="cd" && opcd[1]=="assig" && opcd.size==3
|
458
|
-
if @deep==ORGS
|
459
|
-
self.cdassig(opcd[2])
|
460
|
-
end
|
461
|
-
when op == "people" then self.people()
|
462
|
-
when op == "teams"
|
463
|
-
if @deep==ORGS
|
464
|
-
t.show_teams_bs(@client,@config)
|
465
|
-
end
|
466
|
-
when op == "commits" then self.commits()
|
467
|
-
when op == "issues"
|
468
|
-
if @deep==ORGS_REPO || @deep==USER_REPO || @deep==TEAM_REPO
|
469
|
-
@issues_list=r.show_issues(@client,@config,@deep)
|
470
|
-
end
|
471
|
-
when op == "col" then self.collaborators()
|
472
|
-
when op == "forks" then self.show_forks()
|
473
|
-
when op == "groups"
|
474
|
-
if @deep==ORGS
|
475
|
-
t.list_groups(@client,@config)
|
476
|
-
@sysbh.add_history_str(2,t.get_groupslist(@config))
|
477
|
-
end
|
478
|
-
when op.include?("group") && opcd[0]=="group"
|
479
|
-
if opcd.size==2
|
480
|
-
teams=t.get_single_group(@config,opcd[1])
|
481
|
-
if teams!=nil
|
482
|
-
puts "Teams in group #{opcd[1]} :"
|
483
|
-
puts teams
|
484
|
-
else
|
485
|
-
puts "Group not found"
|
486
|
-
end
|
487
|
-
end
|
488
|
-
when op.include?("new") && opcd[0]=="new" && opcd[1]=="team" #new's parse
|
489
|
-
if opcd.size==3 and @deep==ORGS
|
490
|
-
t.create_team(@client,@config,opcd[2])
|
491
|
-
@teamlist=t.read_teamlist(@client,@config)
|
492
|
-
@sysbh.add_history_str(1,@teamlist)
|
493
|
-
end
|
494
|
-
if opcd.size>3 and @deep==ORGS
|
495
|
-
t.create_team_with_members(@client,@config,opcd[2],opcd[3..opcd.size])
|
496
|
-
@teamlist=t.read_teamlist(@client,@config)
|
497
|
-
@sysbh.add_history_str(1,@teamlist)
|
498
|
-
end
|
499
|
-
when op.include?("new") && !op.include?("comment") && opcd[0]=="new" && opcd[1]=="issue"
|
500
|
-
if opcd.size==2 and (@deep==ORGS_REPO || @deep==USER_REPO || @deep==TEAM_REPO)
|
501
|
-
r.create_issue(@client,@config,@deep,config_path)
|
502
|
-
end
|
503
|
-
when op.include?("new") && (opcd[0]=="new" && opcd[1]=="issue" && opcd[2]=="comment")
|
504
|
-
if opcd.size==4 and (@deep==ORGS_REPO || @deep==USER_REPO || @deep==TEAM_REPO)
|
505
|
-
r.add_issue_cm(@client,@config,@deep,opcd[3],config_path)
|
506
|
-
end
|
507
|
-
when op.include?("new") && opcd[0]=="new" && opcd[1]=="people" && opcd[2]=="info"
|
508
|
-
if @deep==ORGS && opcd.size==4 then o.add_people_info(@client,@config,opcd[3],false) end
|
509
|
-
when op.include?("new") && opcd[0]=="new" && opcd[1]=="repository"
|
510
|
-
if opcd.size==3
|
511
|
-
r.create_repository(@client,@config,opcd[2],false,@deep)
|
512
|
-
end
|
513
|
-
when op.include?("new relation") && opcd[0]=="new" && opcd[1]="relation"
|
514
|
-
if opcd.size==3 and @deep==ORGS
|
515
|
-
o.add_people_info(@client,@config,opcd[2],true)
|
516
|
-
end
|
517
|
-
when op.include?("new assignment") && opcd[0]=="new" && opcd[1]="assignment"
|
518
|
-
if opcd.size==3 and @deep==ORGS
|
519
|
-
r.create_repository_by_teamlist(@client,@config,opcd[2],opcd[3,opcd.size],self.get_teamlist(opcd[3,opcd.size]))
|
520
|
-
o.create_assig(@client,@config,opcd[2])
|
521
|
-
@sysbh.add_history(opcd[2])
|
522
|
-
end
|
523
|
-
when op.include?("new group") && opcd[0]=="new" && opcd[1]="group"
|
524
|
-
if opcd.size==5 and @deep==ORGS and opcd[2]=="-f"
|
525
|
-
t.new_group_file(@client,@config,opcd[3],opcd[4])
|
526
|
-
end
|
527
|
-
if opcd.size>3 and @deep==ORGS and !op.include?("-f")
|
528
|
-
t.new_group(@client,@config,opcd[2],opcd[3..opcd.size-1])
|
529
|
-
end
|
530
|
-
|
531
|
-
when op.include?("rm team") && opcd[0]=="rm" && opcd[1]="team" ##rm parse
|
532
|
-
if opcd.size==3
|
533
|
-
@teamlist=t.read_teamlist(@client,@config)
|
534
|
-
if @teamlist[opcd[2]]!=nil
|
535
|
-
t.delete_team(@client,@teamlist[opcd[2]])
|
536
|
-
@sysbh.quit_history(@teamlist[opcd[2]])
|
537
|
-
@teamlist=t.read_teamlist(@client,@config)
|
538
|
-
@sysbh.add_history_str(1,@teamlist)
|
539
|
-
else
|
540
|
-
puts "Team not found"
|
541
|
-
end
|
542
|
-
end
|
543
|
-
|
544
|
-
when op.include?("rm group") && opcd[0]=="rm" && opcd[1]="group"
|
545
|
-
if opcd.size==3 and @deep==ORGS
|
546
|
-
t.delete_group(@config,opcd[2])
|
547
|
-
end
|
548
|
-
if opcd.size==3 and @deep==ASSIG
|
549
|
-
if opcd[2]!="-all"
|
550
|
-
o.rm_assigment_group(@config,@config["Assig"],opcd[2],1)
|
551
|
-
else
|
552
|
-
o.rm_assigment_group(@config,@config["Assig"],opcd[2],2)
|
553
|
-
end
|
554
|
-
end
|
555
|
-
when op.include?("rm student") && opcd[0]=="rm" && opcd[1]="student"
|
556
|
-
if opcd.size==3 and @deep==ASSIG
|
557
|
-
if opcd[2]!="-all"
|
558
|
-
o.rm_assigment_student(@config,@config["Assig"],opcd[2],1)
|
559
|
-
else
|
560
|
-
o.rm_assigment_student(@config,@config["Assig"],opcd[2],2)
|
561
|
-
end
|
562
|
-
end
|
563
|
-
when op.include?("rm repository") && opcd[0]=="rm" && opcd[1]="repository"
|
564
|
-
if @deep==ORGS || @deep==USER || @deep==TEAM
|
565
|
-
r.delete_repository(@client,@config,opcd[2],@deep)
|
566
|
-
if @deep==ORGS
|
567
|
-
@orgs_repos.delete(opcd[2])
|
568
|
-
end
|
569
|
-
end
|
570
|
-
when op.include?("rm repo")&& opcd[0]=="rm" && opcd[1]="repo"
|
571
|
-
if @deep==ASSIG and opcd.size==3
|
572
|
-
o.rm_assigment_repo(@config,@config["Assig"],opcd[2])
|
573
|
-
end
|
574
|
-
when op.include?("rm clone files") && opcd[0]=="rm" && opcd[1]="clone" && opcd[2]="files"
|
575
|
-
if opcd.size>3
|
576
|
-
r.rm_clone(@client,@config,@scope,false,opcd[3])
|
577
|
-
else
|
578
|
-
r.rm_clone(@client,@config,@scope,true,nil)
|
579
|
-
end
|
580
|
-
when op == "info"
|
581
|
-
if @deep==ASSIG then o.show_assig_info(@config,@config["Assig"]) end
|
582
|
-
if @deep==USER_REPO || @deep==TEAM_REPO || @deep==ORGS_REPO then r.info_repository(@client,@config,@deep) end
|
583
|
-
when op== "add repo"
|
584
|
-
if @deep==ASSIG then o.add_repo_to_assig(@client,@config,@config["Assig"],nil) end
|
585
|
-
when op.include?("change repo") && opcd[0]=="change" && opcd[1]=="repo"
|
586
|
-
if @deep==ASSIG
|
587
|
-
if opcd.size>2
|
588
|
-
o.add_repo_to_assig(@client,@config,@config["Assig"],opcd[2])
|
589
|
-
else
|
590
|
-
o.add_repo_to_assig(@client,@config,@config["Assig"],1)
|
591
|
-
end
|
592
|
-
end
|
593
|
-
when op.include?("change sufix") && opcd[0]=="change" && opcd[1]=="sufix"
|
594
|
-
if @deep==ASSIG
|
595
|
-
if opcd.size>2 then o.change_repo_sufix(@config,@config["Assig"],opcd[2]) end
|
596
|
-
end
|
597
|
-
when op=="add students" && @deep==ASSIG
|
598
|
-
o.add_people_to_assig(@client,@config,@config["Assig"])
|
599
|
-
when op.include?("rm")
|
600
|
-
if @deep==ORGS and opcd[1]=="people" and opcd[2]=="info"
|
601
|
-
o.rm_people_info(@client,@config)
|
602
|
-
end
|
603
|
-
when op== "add group"
|
604
|
-
if @deep=ASSIG then o.add_group_to_assig(@client,@config,@config["Assig"]) end
|
605
|
-
when op == "version"
|
606
|
-
puts "GitHub Education Shell v#{Ghedsh::VERSION}"
|
607
|
-
|
608
|
-
when op.include?("add team member") && opcd[0]=="add" && opcd[1]="team" && opcd[2]="member"
|
609
|
-
if opcd.size==4 and @deep==TEAM
|
610
|
-
t.add_to_team(@client,@config,opcd[3])
|
611
|
-
end
|
612
|
-
|
613
|
-
when op.include?("close issue") && opcd[0]=="close" && opcd[1]="issue"
|
614
|
-
if (@deep==ORGS_REPO || @deep==USER_REPO || @deep==TEAM_REPO) and opcd.size==3
|
615
|
-
r.close_issue(@client,@config,@deep,opcd[2])
|
616
|
-
end
|
617
|
-
|
618
|
-
when op.include?("open issue") && opcd[0]=="open" && opcd[1]="issue"
|
619
|
-
if (@deep==ORGS_REPO || @deep==USER_REPO || @deep==TEAM_REPO) and opcd.size==3
|
620
|
-
r.open_issue(@client,@config,@deep,opcd[2])
|
621
|
-
end
|
622
|
-
|
623
|
-
when op == "assignments"
|
624
|
-
if @deep==ORGS
|
625
|
-
o.show_assignments(@client,@config)
|
626
|
-
@sysbh.add_history_str(2,o.get_assigs(@client,@config,false))
|
627
|
-
end
|
628
|
-
when op =="make"
|
629
|
-
if @deep==ASSIG
|
630
|
-
o.make_assig(@client,@config,@config["Assig"])
|
631
|
-
end
|
632
|
-
when op.include?("open") && opcd[0]=="open"
|
633
|
-
if @deep==USER_REPO || @deep==TEAM_REPO || @deep==ORGS_REPO then r.open_repository(@client,@config,@deep) end
|
634
|
-
if @deep==USER then u.open_user(@client) end
|
635
|
-
if @deep==ORGS
|
636
|
-
if opcd.size==1
|
637
|
-
o.open_org(@client,@config)
|
638
|
-
else
|
639
|
-
if opcd.size==2
|
640
|
-
o.open_user_url(@client,@config,opcd[1],nil)
|
641
|
-
else
|
642
|
-
o.open_user_url(@client,@config,opcd[1],opcd[2])
|
643
|
-
end
|
644
|
-
end
|
645
|
-
end
|
646
|
-
if @deep==TEAM then t.open_team_repos(@config) end
|
647
|
-
if @deep==ASSIG then o.open_assig(@config,@config["Assig"]) end
|
648
|
-
end
|
649
|
-
|
650
|
-
if opcd[0]=="issue" and opcd.size>1
|
651
|
-
if @deep==ORGS_REPO || @deep==USER_REPO || @deep==TEAM_REPO
|
652
|
-
r.show_issue(@client,@config,@deep,opcd[1])
|
653
|
-
end
|
654
|
-
end
|
655
|
-
|
656
|
-
if opcd[0]=="cd" and opcd[1]!=".."
|
657
|
-
if opcd[1]=="/" or opcd.size==1
|
658
|
-
self.cdback(true)
|
659
|
-
else
|
660
|
-
if opcd[1]=="repo" and opcd.size>2
|
661
|
-
self.set(opcd[2])
|
662
|
-
else
|
663
|
-
if opcd[1].include?("/")
|
664
|
-
cdlist=opcd[1].split("/")
|
665
|
-
cdlist.each do |i|
|
666
|
-
opscript.push("cd #{i}")
|
667
|
-
end
|
668
|
-
else
|
669
|
-
self.cd(opcd[1])
|
670
|
-
end
|
671
|
-
end
|
672
|
-
end
|
673
|
-
end
|
674
|
-
if opcd[0]=="do" and opcd.size>1
|
675
|
-
opscript=s.load_script(opcd[1])
|
676
|
-
end
|
677
|
-
if opcd[0]=="set"
|
678
|
-
self.set(opcd[1])
|
679
|
-
end
|
680
|
-
if opcd[0]=="repos" and opcd.size==1
|
681
|
-
self.repos(false)
|
682
|
-
end
|
683
|
-
if opcd[0]=="repos" and opcd.size>1 ##Busca con expresion regular, si no esta en la cache realiza la consulta
|
684
|
-
if opcd[1]=="-all" || opcd[1]=="-a"
|
685
|
-
self.repos(true)
|
686
|
-
else
|
687
|
-
case
|
688
|
-
when @deep==USER
|
689
|
-
if @repos_list.empty?
|
690
|
-
r.show_repos(@client,@config,@deep,opcd[1])
|
691
|
-
@repos_list=r.get_repos_list(@client,@config,@deep)
|
692
|
-
else
|
693
|
-
@sysbh.showcachelist(@repos_list,opcd[1])
|
694
|
-
end
|
695
|
-
when @deep==ORGS
|
696
|
-
if @orgs_repos.empty?
|
697
|
-
r.show_repos(@client,@config,@deep,opcd[1])
|
698
|
-
@orgs_repos=r.get_repos_list(@client,@config,@deep)
|
699
|
-
else
|
700
|
-
@sysbh.showcachelist(@orgs_repos,opcd[1])
|
701
|
-
end
|
702
|
-
when @deep==TEAM
|
703
|
-
if @teams_repos.empty?
|
704
|
-
r.show_repos(@client,@config,@deep,opcd[1])
|
705
|
-
@teams_repos=r.get_repos_list(@client,@config,@deep)
|
706
|
-
else
|
707
|
-
@sysbh.showcachelist(@teams_repos,opcd[1])
|
708
|
-
end
|
709
|
-
end
|
710
|
-
end
|
711
|
-
end
|
712
|
-
|
713
|
-
if opcd[0]=="private" and opcd.size==2
|
714
|
-
if opcd[1]=="true" || opcd[1]=="false"
|
715
|
-
r.edit_repository(@client,@config,@deep,opcd[1])
|
716
|
-
end
|
717
|
-
end
|
718
|
-
|
719
|
-
if opcd[0]=="people" and opcd[1]=="info"
|
720
|
-
if opcd.size==2
|
721
|
-
info_strm=o.show_people_info(@client,@config,nil)
|
722
|
-
if info_strm!=nil then @sysbh.add_history_str(2,info_strm) end
|
723
|
-
else
|
724
|
-
if opcd[2].include?("/")
|
725
|
-
o.search_rexp_people_info(@client,@config,opcd[2])
|
67
|
+
def run
|
68
|
+
puts @shell_enviroment.client.say('GitHub Education Shell')
|
69
|
+
sleep(1.5)
|
70
|
+
@shell_enviroment.client.say.clear
|
71
|
+
system('clear')
|
72
|
+
|
73
|
+
loop do
|
74
|
+
begin
|
75
|
+
input = Readline.readline(@shell_enviroment.prompt, true)
|
76
|
+
# handle ctrl-d (eof), equivalent to exit (saving configuration)
|
77
|
+
if input.nil?
|
78
|
+
@shell_enviroment.commands['exit'].call(nil)
|
79
|
+
exit!(0)
|
80
|
+
end
|
81
|
+
input = input.strip.split
|
82
|
+
command_name = input[0]
|
83
|
+
input.shift
|
84
|
+
command_params = input
|
85
|
+
unless command_name.to_s.empty?
|
86
|
+
if command_name.start_with?('!')
|
87
|
+
command_name = command_name.delete('!')
|
88
|
+
command_params.unshift(command_name)
|
89
|
+
@shell_enviroment.commands['bash'].call(command_params)
|
90
|
+
elsif @shell_enviroment.commands.key?(command_name)
|
91
|
+
result = @shell_enviroment.commands[command_name].call(command_params)
|
726
92
|
else
|
727
|
-
|
93
|
+
puts Rainbow("-ghedsh: #{command_name}: command not found").yellow
|
728
94
|
end
|
729
95
|
end
|
96
|
+
rescue StandardError => e
|
97
|
+
puts e
|
730
98
|
end
|
731
|
-
if
|
732
|
-
if opcd.size==2
|
733
|
-
r.clone_repo(@client,@config,opcd[1],@deep)
|
734
|
-
end
|
735
|
-
if opcd.size==1 && (@deep==USER_REPO || @deep==TEAM_REPO || @deep==ORGS_REPO)
|
736
|
-
r.clone_repo(@client,@config,nil,@deep)
|
737
|
-
end
|
738
|
-
if opcd.size==1 && deep==ASSIG
|
739
|
-
r.clone_repo(@client,@config,"/#{@config["Assig"]}/",@deep)
|
740
|
-
puts "/#{@config["Assig"]}/"
|
741
|
-
end
|
742
|
-
end
|
743
|
-
if op.match(/^!/)
|
744
|
-
op=op.split("!")
|
745
|
-
s.execute_bash(op[1])
|
746
|
-
end
|
747
|
-
if opcd[0]=="clone" and opcd.size>2
|
748
|
-
#r.clone_repo(@client,@config,opcd[1])
|
749
|
-
end
|
750
|
-
if opcd[0]=="files"
|
751
|
-
if opcd.size==1
|
752
|
-
r.get_files(@client,@config,@repo_path,true,@deep)
|
753
|
-
else
|
754
|
-
r.get_files(@client,@config,opcd[1],true,@deep)
|
755
|
-
end
|
756
|
-
end
|
757
|
-
if opcd[0]=="cat" and opcd.size>1
|
758
|
-
r.cat_file(@client,@config,opcd[1],@deep)
|
759
|
-
end
|
99
|
+
break if result == 0
|
760
100
|
end
|
761
|
-
|
762
101
|
end
|
763
|
-
|
764
102
|
end
|