ghedsh 1.1.6 → 1.1.7
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.
- checksums.yaml +4 -4
- data/lib/actions/help.rb +7 -4
- data/lib/actions/system.rb +45 -1
- data/lib/interface.rb +24 -12
- data/lib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3164a5b2130e36eeff5c5364fcec9223955c53f8
|
4
|
+
data.tar.gz: 01b013251710f96572b5a6c9d2f7bcffbfaa454d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65ad1922ca1004d8f0530f265c88be73fc675bcf3d0a0d852e970dc59b6550e6800d021bc32d854c1efb8033b9e28ec947f80460dca793eba18bdd0071407c25
|
7
|
+
data.tar.gz: f68d6cd15712ec424773649c4959866c242f078c9b6550d76ad7a0ee648ad7e404f23e4d6d0b992a753e980904bd203db1ce970e3fbe2246410be5bc9dc42fdc
|
data/lib/actions/help.rb
CHANGED
@@ -5,7 +5,7 @@ class HelpM
|
|
5
5
|
self.common_opt
|
6
6
|
print "orgs => show your organizations\n"
|
7
7
|
print "repos => list your repositories\n\n"
|
8
|
-
print "clone_repo => clone a repository or a list of repositories using a regular expresion"
|
8
|
+
print "clone_repo => clone a repository or a list of repositories using a regular expresion\n"
|
9
9
|
print "create_repository => create a repository in your personal account\n"
|
10
10
|
print "set => move you to a specific repository\n"
|
11
11
|
|
@@ -14,7 +14,7 @@ class HelpM
|
|
14
14
|
def org()
|
15
15
|
self.common_opt
|
16
16
|
print "repos => list the repositories of your organization\n"
|
17
|
-
print "clone_repo => clone a repository or a list of repositories using a regular expresion"
|
17
|
+
print "clone_repo => clone a repository or a list of repositories using a regular expresion\n"
|
18
18
|
print "set => move you to a specific repository\n"
|
19
19
|
print "members => members of a organization\n"
|
20
20
|
print "teams => teams of a organization\n"
|
@@ -32,7 +32,7 @@ class HelpM
|
|
32
32
|
def orgs_teams()
|
33
33
|
self.common_opt
|
34
34
|
print "members => members of the team\n"
|
35
|
-
print "clone_repo => clone a repository or a list of repositories using a regular expresion"
|
35
|
+
print "clone_repo => clone a repository or a list of repositories using a regular expresion\n"
|
36
36
|
print "create_repository => create a repository to this team\n"
|
37
37
|
print "add_to_team => add a member in the team\n\n"
|
38
38
|
end
|
@@ -48,6 +48,7 @@ class HelpM
|
|
48
48
|
print "exit => exit from this program\n"
|
49
49
|
print "help => list of commands available\n"
|
50
50
|
print "cd => go to the path\n"
|
51
|
+
print "! => execute a bash command\n"
|
51
52
|
end
|
52
53
|
|
53
54
|
def welcome
|
@@ -61,9 +62,11 @@ class HelpM
|
|
61
62
|
puts "Run with default configuration. Configuration files are being set in #{ENV['HOME']}"
|
62
63
|
puts "ghedsh --token TOKEN"
|
63
64
|
puts "Provides a github access token by argument. Also works with ghedsh -t"
|
65
|
+
puts "ghedsh --user USERNAME"
|
66
|
+
puts "Change your user from your user's list. Also works with ghedsh -u"
|
64
67
|
puts "ghedsh --version"
|
65
68
|
puts "Show the current version of GHEDSH. Also works with ghedsh -v"
|
66
69
|
puts "ghedsh --help"
|
67
|
-
|
70
|
+
print "Show the executable options. Also works with ghedsh -h\n\n"
|
68
71
|
end
|
69
72
|
end
|
data/lib/actions/system.rb
CHANGED
@@ -21,6 +21,12 @@ class Sys
|
|
21
21
|
if token!=""
|
22
22
|
@client=self.login(token)
|
23
23
|
config["User"]=@client.login
|
24
|
+
userslist=self.load_users(configure_path)
|
25
|
+
|
26
|
+
if userslist["#{config["User"]}"]==nil
|
27
|
+
userslist["#{config["User"]}"]=token
|
28
|
+
self.save_users(configure_path,userslist)
|
29
|
+
end
|
24
30
|
if argv_token!=nil
|
25
31
|
self.save_token(configure_path,argv_token)
|
26
32
|
end
|
@@ -34,6 +40,32 @@ class Sys
|
|
34
40
|
end
|
35
41
|
end
|
36
42
|
|
43
|
+
def load_config_user(configure_path, user)
|
44
|
+
if File.exist?(configure_path)
|
45
|
+
list=self.load_users(configure_path)
|
46
|
+
if list["#{user}"]!=nil
|
47
|
+
json = File.read("#{configure_path}/ghedsh-cache.json")
|
48
|
+
config=JSON.parse(json)
|
49
|
+
@client=self.login(list["#{user}"])
|
50
|
+
config["User"]=@client.login
|
51
|
+
self.save_token(configure_path,list["#{user}"])
|
52
|
+
return config
|
53
|
+
else
|
54
|
+
puts "User not found"
|
55
|
+
return nil
|
56
|
+
end
|
57
|
+
else
|
58
|
+
puts "No user's history is available"
|
59
|
+
return nil
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def load_users(path)
|
64
|
+
json=File.read("#{path}/ghedsh-users.json")
|
65
|
+
users=JSON.parse(json)
|
66
|
+
return users
|
67
|
+
end
|
68
|
+
|
37
69
|
def save_token(path,token)
|
38
70
|
File.write("#{path}/ghedsh-token",token)
|
39
71
|
end
|
@@ -51,9 +83,13 @@ class Sys
|
|
51
83
|
puts "Insert you Access Token: "
|
52
84
|
token = gets.chomp
|
53
85
|
us=self.login(token)
|
86
|
+
userhash=Hash.new
|
87
|
+
|
54
88
|
if us!=nil
|
55
89
|
puts "Login succesful as #{us.login}\n"
|
56
90
|
config["User"]=us.login
|
91
|
+
userhash["#{config["User"]}"]=token
|
92
|
+
self.save_users(configure_path,userhash)
|
57
93
|
File.write("#{configure_path}/ghedsh-token",token) #config["Token"]=token
|
58
94
|
@client=us
|
59
95
|
return config
|
@@ -73,22 +109,30 @@ class Sys
|
|
73
109
|
|
74
110
|
def create_config(configure_path)
|
75
111
|
con={:User=>nil,:Org=>nil,:Repo=>nil,:Team=>nil,:TeamID=>nil}
|
112
|
+
us={}
|
76
113
|
FileUtils.mkdir_p(configure_path)
|
77
114
|
File.new("#{configure_path}/ghedsh-token","w")
|
78
115
|
File.write("#{configure_path}/ghedsh-cache.json",con.to_json)
|
116
|
+
File.write("#{configure_path}/ghedsh-users.json",us.to_json)
|
79
117
|
puts "Confiration files created in #{configure_path}"
|
80
118
|
end
|
81
119
|
|
82
120
|
|
83
121
|
def save_cache(path,data)
|
84
|
-
File.write(
|
122
|
+
File.write("#{path}/ghedsh-cache.json",data.to_json)
|
85
123
|
end
|
86
124
|
|
87
125
|
def save_db(path,data)
|
88
126
|
File.write("#{path}/db/assignments.json", data.to_json)
|
89
127
|
end
|
90
128
|
|
129
|
+
def save_users(path,data)
|
130
|
+
File.write("#{path}/ghedsh-users.json",data.to_json)
|
131
|
+
end
|
91
132
|
|
133
|
+
def execute_bash(exp)
|
134
|
+
system(exp)
|
135
|
+
end
|
92
136
|
|
93
137
|
def search_rexp(list,exp)
|
94
138
|
list= list.select{|o| o.match(/#{exp}/)}
|
data/lib/interface.rb
CHANGED
@@ -25,20 +25,22 @@ class Interface
|
|
25
25
|
@sysbh=Sys.new()
|
26
26
|
|
27
27
|
if ARGV.empty?
|
28
|
-
#self.run('./.ghedsh',nil)
|
29
|
-
self.run("#{ENV['HOME']}/.ghedsh",nil)
|
28
|
+
#self.run('./.ghedsh',nil,nil)
|
29
|
+
self.run("#{ENV['HOME']}/.ghedsh",nil,nil)
|
30
30
|
else
|
31
31
|
case
|
32
32
|
when ARGV[0]=="--configpath" || ARGV[0]=="-c"
|
33
33
|
if File.exist?(ARGV[1])
|
34
|
-
self.run(ARGV[1],nil)
|
34
|
+
self.run(ARGV[1],nil,nil)
|
35
35
|
else
|
36
36
|
puts "the path doesn't exists"
|
37
37
|
end
|
38
38
|
when ARGV[0]=="--help" || ARGV[0]=="-h"
|
39
39
|
HelpM.new.bin()
|
40
40
|
when ARGV[0]=="--token" || ARGV[0]=="-t"
|
41
|
-
self.run('
|
41
|
+
self.run("#{ENV['HOME']}/.ghedsh",ARGV[1],nil)
|
42
|
+
when ARGV[0]=="--user" || ARGV[0]=="-u"
|
43
|
+
self.run("#{ENV['HOME']}/.ghedsh",nil,ARGV[1])
|
42
44
|
when ARGV[0]=="--version" || ARGV[0]=="-v"
|
43
45
|
puts "GitHub Education Shell v#{Ghedsh::VERSION}"
|
44
46
|
end
|
@@ -113,7 +115,6 @@ class Interface
|
|
113
115
|
|
114
116
|
def cdback()
|
115
117
|
case
|
116
|
-
#when @deep == 1 then @config["User"]=nil
|
117
118
|
when @deep == 2
|
118
119
|
@config["Org"]=nil
|
119
120
|
@deep=1
|
@@ -143,7 +144,6 @@ class Interface
|
|
143
144
|
@config["Team"]=path
|
144
145
|
@config["TeamID"]=@teamlist[path]
|
145
146
|
@deep=4
|
146
|
-
#self.get_data
|
147
147
|
end
|
148
148
|
end
|
149
149
|
|
@@ -226,7 +226,7 @@ class Interface
|
|
226
226
|
end
|
227
227
|
end
|
228
228
|
|
229
|
-
def run(config_path, argv_token)
|
229
|
+
def run(config_path, argv_token,user)
|
230
230
|
ex=1
|
231
231
|
@memory=[]
|
232
232
|
history=LIST+memory
|
@@ -240,17 +240,28 @@ class Interface
|
|
240
240
|
s=Sys.new
|
241
241
|
# orden de búsqueda: ~/.ghedsh.json ./ghedsh.json ENV["ghedsh"] --configpath path/to/file.json
|
242
242
|
|
243
|
+
if user!=nil
|
244
|
+
@config=s.load_config_user(config_path,user)
|
245
|
+
@client=s.client
|
246
|
+
if @config==nil
|
247
|
+
ex=0
|
248
|
+
end
|
249
|
+
else
|
250
|
+
@config=s.load_config(config_path,argv_token)
|
251
|
+
@client=s.client
|
252
|
+
end
|
243
253
|
|
244
|
-
@config=s.load_config(config_path,argv_token)
|
245
|
-
@client=s.client
|
246
254
|
@deep=1
|
247
|
-
|
255
|
+
if @client!=nil
|
256
|
+
self.add_history_str(2,Organizations.new.read_orgs(@client))
|
257
|
+
end
|
248
258
|
|
249
259
|
while ex != 0
|
250
260
|
op=Readline.readline(self.prompt,true)
|
251
261
|
opcd=op.split
|
252
262
|
case
|
253
263
|
when op == "exit" then ex=0
|
264
|
+
s.save_cache(config_path,@config)
|
254
265
|
when op == "help" then self.help()
|
255
266
|
when op == "orgs" then self.orgs()
|
256
267
|
when op == "cd .." then self.cdback()
|
@@ -316,13 +327,14 @@ class Interface
|
|
316
327
|
if opcd[0]=="clone_repo" and opcd.size==2
|
317
328
|
r.clone_repo(@client,@config,opcd[1],@deep)
|
318
329
|
end
|
319
|
-
|
330
|
+
if opcd[0]=="!"
|
331
|
+
s.execute_bash(opcd[1])
|
332
|
+
end
|
320
333
|
if opcd[0]=="clone_repo" and opcd.size>2
|
321
334
|
#r.clone_repo(@client,@config,opcd[1])
|
322
335
|
end
|
323
336
|
end
|
324
337
|
|
325
|
-
s.save_cache(config_path,@config)
|
326
338
|
end
|
327
339
|
|
328
340
|
end
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ghedsh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Javier Clemente
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-04-
|
12
|
+
date: 2016-04-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: octokit
|