ghedsh 1.1.10 → 1.1.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 10c27568227695c5e7166c854a1e58e3ac74908c
4
- data.tar.gz: 472ff14bd2ddc02686f346ca74b1f2935d360b35
3
+ metadata.gz: d284d3044a823a0685dc8000446c04121025c9b5
4
+ data.tar.gz: c1d9b80bd3e9b7212b33901493221ac90ead897a
5
5
  SHA512:
6
- metadata.gz: 228dc8b4b3dbaff83deb9f4dde4e555063ee14ef598004387a9d8d681fcc637fe381c655639ea69fe92f92b5dd97f68d2bb27fc401d9eef245a73cd062f901aa
7
- data.tar.gz: eb5604973f82e1ad6eab5f91adf885ae1bbe61b35bbf9949144b7b0ddeadbc9d0c287d0bfc08fe9d825739e9952d59112db8abbc3989bf0fe9d9fb8d180ff814
6
+ metadata.gz: 800d79a32bdfd1aeeecd14a4d72ac930d7a9d624f626c59b51c6cb10638bbf7adeffa37e34caeea1a782787f9b2b2b501301a4d72c49df827bf63f6ce2c37a5a
7
+ data.tar.gz: efa095937b48289ee543e081f37a5f201a93042b5a98be524524bb22df986ad51d63582706bf2f40b38bcc54da3129d9d38cca79f3af743eb8ccfd2d96e9694d
data/lib/actions/help.rb CHANGED
@@ -1,54 +1,59 @@
1
1
 
2
2
  class HelpM
3
+ attr_reader :user
4
+ attr_reader :org_repo
5
+ attr_reader :org_teams
6
+ attr_reader :user_repo
7
+ attr_reader :common_opt
3
8
 
4
9
  def user()
5
10
  self.common_opt
6
- print "orgs => show your organizations\n"
7
- print "repos => list your repositories\n\n"
8
- print "clone_repo => clone a repository or a list of repositories using a regular expresion\n"
9
- print "create_repository => create a repository in your personal account\n"
10
- print "set => move you to a specific repository\n"
11
+ print "\torgs\t\t\tshow your organizations\n"
12
+ print "\trepos\t\t\tlist your repositories\n\n"
13
+ print "\tclone\t\t\tclone a repository or a list of repositories using a regular expresion\n"
14
+ print "\tnew_repository\t\tcreate a repository in your personal account\n"
15
+ print "\tset\t\t\tmove you to a specific repository\n"
11
16
 
12
17
  end
13
18
 
14
19
  def org()
15
20
  self.common_opt
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\n"
18
- print "set => move you to a specific repository\n"
19
- print "members => members of a organization\n"
20
- print "teams => teams of a organization\n"
21
- print "create_repository => create a repository in your organization\n"
22
- print "delete_team => delete a team in you organization. Expected the name of the team\n"
23
- print "create_team => create a team in the organization. Expected the name of the team, and/or members given one by one\n\n"
21
+ print "\trepos\t\t\tlist the repositories of your organization\n"
22
+ print "\tclone\t\t\tclone a repository or a list of repositories using a regular expresion\n"
23
+ print "\tset\t\t\tmove you to a specific repository\n"
24
+ print "\tpeople\t\t\tmembers of a organization\n"
25
+ print "\tteams\t\t\tteams of a organization\n"
26
+ print "\tnew_assignment\t\tcreate a repository in your organization\n"
27
+ print "\trm_team\t\t\tdelete a team in you organization. Expected the name of the team\n"
28
+ print "\tnew_team\t\t\tcreate a team in the organization. Expected the name of the team, and/or members given one by one\n\n"
24
29
  end
25
30
 
26
31
  def org_repo()
27
32
  self.common_opt
28
- print "commits => show the list of commits from the repository\n"
29
- print "col => show the list of collaborators from the repository\n\n"
33
+ print "\tcommits\t\t\tshow the list of commits from the repository\n"
34
+ print "\tcol\t\t\tshow the list of collaborators from the repository\n\n"
30
35
  end
31
36
 
32
37
  def orgs_teams()
33
38
  self.common_opt
34
- print "members => members of the team\n"
35
- print "clone_repo => clone a repository or a list of repositories using a regular expresion\n"
36
- print "create_repository => create a repository to this team\n"
37
- print "add_to_team => add a member in the team\n\n"
39
+ print "\tpeople\t\t\tmembers of the team\n"
40
+ print "\tclone\t\t\tclone a repository or a list of repositories using a regular expresion\n"
41
+ print "\tnew_repository\t\tcreate a repository to this team\n"
42
+ print "\tadd_to_team\t\t\tadd a member in the team\n\n"
38
43
  end
39
44
 
40
45
  def user_repo()
41
46
  self.common_opt
42
- print "commits => show the list of commits from the repository\n"
43
- print "col => show the list of collaborators from the repository\n\n"
47
+ print "\tcommits\t\t\tshow the list of commits from the repository\n"
48
+ print "\tcol\t\t\tshow the list of collaborators from the repository\n\n"
44
49
  end
45
50
 
46
51
  def common_opt()
47
- puts "\nList of commands.\n"
48
- print "exit => exit from this program\n"
49
- print "help => list of commands available\n"
50
- print "cd => go to the path\n"
51
- print "! => execute a bash command\n"
52
+ puts "\nList of commands\n"
53
+ print "\texit\t\t\texit from this program\n"
54
+ print "\thelp\t\t\tlist of commands available\n"
55
+ print "\tcd\t\t\tgo to the path\n"
56
+ print "\t!\t\t\texecute a bash command\n"
52
57
  end
53
58
 
54
59
  def welcome
@@ -56,17 +61,4 @@ class HelpM
56
61
  puts "_______________________\n\n"
57
62
  end
58
63
 
59
- def bin
60
- puts "\nList of commands\n\n"
61
- puts "ghedsh"
62
- puts "Run with default configuration. Configuration files are being set in #{ENV['HOME']}"
63
- puts "ghedsh --token TOKEN"
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"
67
- puts "ghedsh --version"
68
- puts "Show the current version of GHEDSH. Also works with ghedsh -v"
69
- puts "ghedsh --help"
70
- print "Show the executable options. Also works with ghedsh -h\n\n"
71
- end
72
64
  end
data/lib/actions/repo.rb CHANGED
@@ -1,16 +1,22 @@
1
1
  require 'readline'
2
2
  require 'octokit'
3
3
  require 'json'
4
+ require 'readline'
4
5
  require 'require_all'
5
6
  require_rel '.'
6
7
 
7
8
 
8
9
  class Repositories
9
10
 
11
+ attr_reader :reposlist
10
12
  #scope = 1 -> organization repos
11
13
  #scope = 2 -> user repos
12
14
  #scope = 3 -> team repos
13
15
 
16
+ def initialize
17
+ @reposlist=[]
18
+ end
19
+
14
20
  def show_commits(client,config,scope)
15
21
  print "\n"
16
22
  case
@@ -24,9 +30,11 @@ class Repositories
24
30
  end
25
31
  end
26
32
 
33
+ #Show repositories and return a list of them
34
+ #exp = regular expression
27
35
  def show_repos(client,config,scope,exp)
28
36
  print "\n"
29
- reposlist=[]
37
+ rlist=[]
30
38
  options=Hash.new
31
39
  o=Organizations.new
32
40
  regex=false
@@ -35,42 +43,55 @@ class Repositories
35
43
  if exp.match(/^\//)
36
44
  regex=true
37
45
  sp=exp.split('/')
38
- exp=sp[1]
46
+ exp=Regexp.new(sp[1],sp[2])
39
47
  end
40
48
  end
41
49
 
42
50
  case
43
51
  when scope==1
44
- #options[:affiliation]="organization_member"
45
52
  repo=client.repositories(options) #config["User"]
46
53
  listorgs=o.read_orgs(client)
47
- #self.show_user_orgs_repos(client,config,listorgs)
48
54
 
49
55
  when scope==2
50
56
  repo=client.organization_repositories(config["Org"])
51
57
  when scope==3
52
58
  repo=client.team_repositories(config["TeamID"])
53
59
  end
60
+
61
+ counter=0
62
+ allpages=true
63
+
54
64
  repo.each do |i|
55
65
  if regex==false
66
+ if counter==100 && allpages==true
67
+ op=Readline.readline("\nThere are more results. Show next repositories (press any key) or Show all repositories (press a): ",true)
68
+ if op=="a"
69
+ allpages=false
70
+ end
71
+ counter=0
72
+ end
73
+
56
74
  puts i.name
57
- reposlist.push(i.name)
75
+ rlist.push(i.name)
76
+ counter=counter+1
58
77
  else
59
78
 
60
- if i.name.match(/#{exp}/)
79
+ if i.name.match(exp)
61
80
  puts i.name
62
- reposlist.push(i.name)
81
+ rlist.push(i.name)
82
+ counter=counter+1
63
83
  end
64
84
  end
65
85
  end
66
- if reposlist.empty?
86
+
87
+ if rlist.empty?
67
88
  puts "No repository matches with that expression"
68
89
  else
69
90
  print "\n"
70
- puts "Repositories found: #{reposlist.size}"
91
+ puts "Repositories found: #{rlist.size}"
71
92
  end
72
93
 
73
- return reposlist
94
+ return rlist
74
95
  end
75
96
 
76
97
  def show_user_orgs_repos(client,config,listorgs)
@@ -154,6 +175,7 @@ class Repositories
154
175
  end
155
176
  end
156
177
 
178
+ #Gete the repository list from a given scope
157
179
  def get_repos_list(client,config,scope)
158
180
  reposlist=[]
159
181
  case
@@ -170,6 +192,8 @@ class Repositories
170
192
  return reposlist
171
193
  end
172
194
 
195
+ #clone repositories
196
+ #exp = regular expression
173
197
  def clone_repo(client,config,exp,scope)
174
198
  web="https://github.com/"
175
199
  web2="git@github.com:"
@@ -7,8 +7,56 @@ require 'actions/system'
7
7
  require 'version'
8
8
 
9
9
  class Sys
10
- attr_accessor :client
10
+ attr_reader :client
11
+ attr_reader :memory
12
+ LIST = ['repos', 'exit', 'orgs','help', 'people','teams', 'cd ', 'cd repo ','commits','forks', 'add_team_member ','new_team ','rm_team ','new_repository ','new_assignment ','clone '].sort
11
13
 
14
+ def initialize()
15
+ @memory=[]
16
+ end
17
+
18
+ # CACHE READLINE METHODS
19
+ def add_history(value)
20
+ @memory.push(value)
21
+ self.write_memory
22
+ end
23
+
24
+ def quit_history(value)
25
+ @memory.pop(value)
26
+ self.write_memory
27
+ end
28
+
29
+ def add_history_str(mode,value)
30
+ if mode==1
31
+ value.each do |i|
32
+ @memory.push(i[0])
33
+ self.write_memory
34
+ end
35
+ end
36
+ if mode==2
37
+ value.each do |i|
38
+ @memory.push(i)
39
+ self.write_memory
40
+ end
41
+ end
42
+ end
43
+ def write_memory
44
+ history=(LIST+@memory).sort
45
+ comp = proc { |s| history.grep( /^#{Regexp.escape(s)}/ ) }
46
+ Readline.completion_append_character = ""
47
+ Readline.completion_proc = comp
48
+ end
49
+
50
+ def write_initial_memory
51
+ history=LIST+memory
52
+ comp = proc { |s| LIST.grep( /^#{Regexp.escape(s)}/ ) }
53
+
54
+ Readline.completion_append_character = ""
55
+ Readline.completion_proc = comp
56
+ end
57
+ # END CACHE READLINE METHODS
58
+
59
+ #Loading initial configure, if ghedsh path doesnt exist, call the create method
12
60
  def load_config(configure_path,argv_token)
13
61
  if File.exist?(configure_path)
14
62
  if argv_token==nil
@@ -40,6 +88,7 @@ class Sys
40
88
  end
41
89
  end
42
90
 
91
+ #loading configure with --user mode
43
92
  def load_config_user(configure_path, user)
44
93
  if File.exist?(configure_path)
45
94
  list=self.load_users(configure_path)
@@ -97,6 +146,7 @@ class Sys
97
146
  return user
98
147
  end
99
148
 
149
+ #initial program configure
100
150
  def set_loguin_data_sh(config,configure_path)
101
151
  puts "Insert you Access Token: "
102
152
  token = gets.chomp
@@ -124,6 +174,7 @@ class Sys
124
174
  return config
125
175
  end
126
176
 
177
+ #creates all ghedsh local stuff
127
178
  def create_config(configure_path)
128
179
  con={:User=>nil,:Org=>nil,:Repo=>nil,:Team=>nil,:TeamID=>nil}
129
180
  us={:login=>nil, :users=>[]}
data/lib/interface.rb CHANGED
@@ -20,187 +20,213 @@ TEAM=4
20
20
  TEAM_REPO=5
21
21
 
22
22
  class Interface
23
- attr_reader :option
23
+ attr_reader :option, :sysbh
24
24
  attr_accessor :config
25
25
  attr_accessor :client
26
26
  attr_accessor :deep
27
27
  attr_accessor :memory
28
- attr_reader :teamlist
29
- attr_reader :orgs_list
30
- LIST = ['repos', 'exit', 'orgs','help', 'members','teams', 'cd ', 'commits','forks', 'add_team_member ','create_team ','delete_team ','create_repository ','clone_repo '].sort
28
+ attr_reader :orgs_list,:repos_list, :teamlist, :orgs_repos, :teams_repos
29
+ LIST = ['repos', 'exit', 'orgs','help', 'people','teams', 'cd ', 'cd repo ','commits','forks', 'add_team_member ','new_team ','rm_team ','new_repository ','new_assignment ','clone '].sort
31
30
 
32
31
  def initialize
33
- sysbh=Sys.new()
34
- options=sysbh.parse
35
- begin
36
- if options[:user]==nil && options[:token]==nil && options[:path]!=nil
37
- self.run(options[:path],options[:token],options[:user])
38
- else
39
- self.run("#{ENV['HOME']}/.ghedsh",options[:token],options[:user])
40
- end
41
- rescue SystemExit, Interrupt
42
- raise
43
- rescue Exception => e
44
- puts "exit"
45
- end
46
-
47
- end
48
-
49
- def add_history(value)
50
- @memory.push(value)
51
- self.write_memory
52
- end
53
-
54
- def quit_history(value)
55
- @memory.pop(value)
56
- self.write_memory
57
- end
58
-
59
- def add_history_str(mode,value)
60
- if mode==1
61
- value.each do |i|
62
- @memory.push(i[0])
63
- self.write_memory
64
- end
65
- end
66
- if mode==2
67
- value.each do |i|
68
- @memory.push(i)
69
- self.write_memory
32
+ @sysbh=Sys.new()
33
+ @repos_list=[]; @orgs_repos=[]
34
+
35
+ options=@sysbh.parse
36
+
37
+ trap("SIGINT") { throw :ctrl_c }
38
+ catch :ctrl_c do
39
+ begin
40
+ if options[:user]==nil && options[:token]==nil && options[:path]!=nil
41
+ self.run(options[:path],options[:token],options[:user])
42
+ else
43
+ self.run("#{ENV['HOME']}/.ghedsh",options[:token],options[:user])
44
+ end
45
+ rescue SystemExit, Interrupt
46
+ raise
47
+ rescue Exception => e
48
+ puts "exit"
49
+ puts e
70
50
  end
71
51
  end
72
52
  end
73
53
 
74
-
75
- def write_memory
76
- history=(LIST+@memory).sort
77
- comp = proc { |s| history.grep( /^#{Regexp.escape(s)}/ ) }
78
- Readline.completion_append_character = ""
79
- Readline.completion_proc = comp
80
- end
81
-
82
-
83
54
  def prompt()
84
55
  case
85
- when @deep == 1 then return @config["User"]+"> "
86
- when @deep == 10 then return @config["User"]+">"+@config["Repo"]+"> "
87
- when @deep == 2 then return @config["User"]+">"+@config["Org"]+"> "
88
- when @deep == 4 then return @config["User"]+">"+@config["Org"]+">"+@config["Team"]+"> "
89
- when @deep == 5 then return @config["User"]+">"+@config["Org"]+">"+@config["Team"]+">"+@config["Repo"]+"> "
90
- when @deep == 3 then return @config["User"]+">"+@config["Org"]+">"+@config["Repo"]+"> "
56
+ when @deep == USER then return @config["User"]+"> "
57
+ when @deep == USER_REPO then return @config["User"]+">"+ "\e[31m#{@config["Repo"]}\e[0m"+"> "
58
+ when @deep == ORGS then return @config["User"]+">"+ "\e[34m#{@config["Org"]}\e[0m"+"> "
59
+ when @deep == TEAM then return @config["User"]+">"+@config["Org"]+">"+@config["Team"]+"> "
60
+ when @deep == TEAM_REPO then return @config["User"]+">"+"\e[34m#{@config["Org"]}\e[0m"+">"+@config["Team"]+">"+"\e[31m#{@config["Repo"]}\e[0m"+"> "
61
+ when @deep == ORGS_REPO then return @config["User"]+">"+"\e[34m#{@config["Org"]}\e[0m"+">"+"\e[31m#{@config["Repo"]}\e[0m"+"> "
91
62
  end
92
63
  end
93
64
 
94
65
  def help()
95
66
  h=HelpM.new()
96
67
  case
97
- when @deep == 1
68
+ when @deep == USER
98
69
  h.user()
99
- when @deep == 2
70
+ when @deep == ORGS
100
71
  h.org()
101
- when @deep == 3
72
+ when @deep == ORGS_REPO
102
73
  h.org_repo()
103
- when @deep == 10
74
+ when @deep == USER_REPO
104
75
  h.user_repo()
105
- when @deep == 4
76
+ when @deep == TEAM
106
77
  h.orgs_teams()
107
78
  end
108
79
  end
109
80
 
110
- def cdback()
111
- case
112
- when @deep == 2
113
- @config["Org"]=nil
114
- @deep=1
115
- when @deep == 3
116
- @config["Repo"]=nil
117
- @deep=2
118
- when @deep == 10
119
- @config["Repo"]=nil
120
- @deep=1
121
- when @deep == 4
122
- @config["Team"]=nil
123
- @config["TeamID"]=nil
124
- @deep=2
81
+ #Go back to any level
82
+ def cdback(returnall)
83
+ if returnall!=true
84
+ case
85
+ when @deep == ORGS
86
+ @config["Org"]=nil
87
+ @deep=1
88
+ when @deep == ORGS_REPO
89
+ @config["Repo"]=nil
90
+ @deep=2
91
+ when @deep == USER_REPO
92
+ @config["Repo"]=nil
93
+ @deep=1
94
+ when @deep == TEAM
95
+ @config["Team"]=nil
96
+ @config["TeamID"]=nil
97
+ @deep=2
98
+ end
99
+ else
100
+ @config["Org"]=nil
101
+ @config["Repo"]=nil
102
+ @config["Team"]=nil
103
+ @config["TeamID"]=nil
104
+ @deep=1
125
105
  end
126
106
  end
127
107
 
108
+ #Go to the path, depends with the scope
109
+ #if you are in user scope, first searchs Orgs then Repos, etc.
128
110
  def cd(path)
129
111
  case
130
- when @deep==1
112
+ when @deep==USER
131
113
  @orgs_list=Organizations.new.read_orgs(@client)
132
114
  aux=@orgs_list
133
115
  if aux.one?{|aux| aux==path}
134
116
  @config["Org"]=path
135
117
  @teamlist=Teams.new.read_teamlist(@client,@config)
136
- self.add_history_str(1,@teamlist)
118
+ #self.add_history_str(1,@teamlist)
119
+ @sysbh.add_history_str(1,@teamlist)
137
120
  @deep=2
138
121
  else
139
- puts "No organization is available with that name"
122
+ puts "\nNo organization is available with that name"
123
+ self.set(path)
140
124
  end
141
- when @deep == 2
125
+ when @deep == ORGS
142
126
  aux=@teamlist
143
127
  if aux[path]!=nil
144
128
  @config["Team"]=path
145
129
  @config["TeamID"]=@teamlist[path]
146
- @deep=4
130
+ @deep=TEAM
147
131
  else
148
- puts "No team is available with that name"
132
+ puts "\nNo team is available with that name"
133
+ self.set(path)
149
134
  end
135
+ when @deep == TEAM
136
+ self.set(path)
150
137
  end
151
138
  end
152
139
 
153
- #set the repo
140
+ #set in the given path repository, first search in the list, then do the github query if list is empty
154
141
  def set(path)
155
142
  reposlist=Repositories.new()
143
+
156
144
  case
157
- when @deep==1
145
+ when @deep==USER
158
146
  @config["Repo"]=path
159
- if reposlist.get_repos_list(@client,@config,@deep).one?{|aux| aux==path}
160
- @deep=10
147
+ if @repos_list.empty? == false
148
+ reposlist=@repos_list
149
+ else
150
+ reposlist=reposlist.get_repos_list(@client,@config,@deep)
161
151
  end
162
- when @deep==2
152
+ if reposlist.one?{|aux| aux==path}
153
+ @deep=USER_REPO
154
+ puts "Set in #{@config["User"]} repository: #{path}\n\n"
155
+ end
156
+ when @deep==ORGS
163
157
  @config["Repo"]=path
164
- if reposlist.get_repos_list(@client,@config,@deep).one?{|aux| aux==path}
165
- @deep=3
158
+ if @orgs_repos.empty? == false
159
+ reposlist=@orgs_repos
160
+ else
161
+ reposlist=reposlist.get_repos_list(@client,@config,@deep)
166
162
  end
167
- when @deep==4
163
+ if reposlist.one?{|aux| aux==path}
164
+ @deep=ORGS_REPO
165
+ puts "Set in #{@config["Org"]} repository: #{path}\n\n"
166
+ end
167
+ when @deep==TEAM
168
168
  @config["Repo"]=path
169
- if reposlist.get_repos_list(@client,@config,@deep).one?{|aux| aux==path}
170
- @deep=5
169
+ if @teams_repos.empty? == false
170
+ repostlist=@teams_repos
171
+ else
172
+ repostlist.get_repos_list(@client,@config,@deep)
173
+ end
174
+ if reposlist.one?{|aux| aux==path}
175
+ @deep=TEAM_REPO
176
+ puts "Set in #{@config["Team"]} repository: #{path}\n\n"
171
177
  end
172
178
  end
173
- if @deep==1 || @deep==2 || @deep==4 then puts "No repository is available with that name" end
179
+ if @deep==USER || @deep==ORGS || @deep==TEAM then puts "No repository is available with that name\n\n" end
174
180
  end
175
181
 
176
182
  def orgs()
177
183
  case
178
- when @deep==1
179
- self.add_history_str(2,Organizations.new.show_orgs(@client,@config))
184
+ when @deep==USER
185
+ #self.add_history_str(2,Organizations.new.show_orgs(@client,@config))
186
+ @sysbh.add_history_str(2,Organizations.new.show_orgs(@client,@config))
180
187
  end
181
188
  end
182
189
 
183
- def members()
190
+ def people()
184
191
  case
185
- when @deep==2
186
- self.add_history_str(2,Organizations.new.show_organization_members_bs(@client,@config))
187
- when @deep==4
188
- self.add_history_str(2,Teams.new.show_team_members_bs(@client,@config))
192
+ when @deep==ORGS
193
+ #self.add_history_str(2,Organizations.new.show_organization_members_bs(@client,@config))
194
+ @sysbh.add_history_str(2,Organizations.new.show_organization_members_bs(@client,@config))
195
+ when @deep==TEAM
196
+ #self.add_history_str(2,Teams.new.show_team_members_bs(@client,@config))
197
+ @sysbh.add_history_str(2,Organizations.new.show_organization_members_bs(@client,@config))
189
198
  end
190
199
  end
191
200
 
192
201
  def repos()
193
202
  repo=Repositories.new()
194
203
  case
195
- when @deep == 1
196
- list=repo.show_repos(@client,@config,1,nil)
197
- self.add_history_str(2,list)
198
- when @deep ==2
199
- list=repo.show_repos(@client,@config,2,nil)
200
- self.add_history_str(2,list)
201
- when @deep==4
202
- list=repo.show_repos(@client,@config,3,nil)
203
- self.add_history_str(2,list)
204
+ when @deep == USER
205
+ if @repos_list.empty?
206
+ list=repo.show_repos(@client,@config,USER,nil)
207
+ #self.add_history_str(2,list)
208
+ @sysbh.add_history_str(2,list)
209
+ @repos_list=list
210
+ else
211
+ puts @repos_list
212
+ end
213
+ when @deep ==ORGS
214
+ if @orgs_repos.empty?
215
+ list=repo.show_repos(@client,@config,ORGS,nil)
216
+ #self.add_history_str(2,list)
217
+ @sysbh.add_history_str(2,list)
218
+ @orgs_repos=list
219
+ else
220
+ puts @orgs_repos
221
+ end
222
+ when @deep==TEAM
223
+ if @teams_repos.empty?
224
+ list=repo.show_repos(@client,@config,TEAM,nil)
225
+ self.add_history_str(2,list)
226
+ @teams_repos=list
227
+ else
228
+ puts @teams_repos
229
+ end
204
230
  end
205
231
  end
206
232
 
@@ -215,9 +241,9 @@ class Interface
215
241
  def commits()
216
242
  c=Repositories.new
217
243
  case
218
- when @deep==3
244
+ when @deep==ORGS_REPO
219
245
  c.show_commits(@client,@config,1)
220
- when @deep==10
246
+ when @deep==USER_REPO
221
247
  c.show_commits(@client,@config,2)
222
248
  end
223
249
  print "\n"
@@ -225,26 +251,23 @@ class Interface
225
251
 
226
252
  def show_forks()
227
253
  case
228
- when @deep==3
254
+ when @deep==ORGS_REPO
229
255
  Repositories.new.show_forks(@client,@config,1)
230
256
  end
231
257
  end
232
258
 
233
259
  def collaborators()
234
260
  case
235
- when @deep==3
261
+ when @deep==ORGS_REPO
236
262
  Repositories.show_collaborators(@client,@config,1)
237
263
  end
238
264
  end
239
265
 
266
+ #Main program
240
267
  def run(config_path, argv_token,user)
241
268
  ex=1
242
- @memory=[]
243
- history=LIST+memory
244
- comp = proc { |s| LIST.grep( /^#{Regexp.escape(s)}/ ) }
245
269
 
246
- Readline.completion_append_character = ""
247
- Readline.completion_proc = comp
270
+ @sysbh.write_initial_memory()
248
271
  HelpM.new.welcome()
249
272
 
250
273
  t=Teams.new
@@ -264,9 +287,10 @@ class Interface
264
287
  @client=s.client
265
288
  end
266
289
 
267
- @deep=1
290
+ @deep=USER
268
291
  if @client!=nil
269
- self.add_history_str(2,Organizations.new.read_orgs(@client))
292
+ #self.add_history_str(2,Organizations.new.read_orgs(@client))
293
+ @sysbh.add_history_str(2,Organizations.new.read_orgs(@client))
270
294
  end
271
295
 
272
296
  while ex != 0
@@ -278,10 +302,10 @@ class Interface
278
302
  s.save_cache(config_path,@config)
279
303
  when op == "help" then self.help()
280
304
  when op == "orgs" then self.orgs()
281
- when op == "cd .." then self.cdback()
282
- when op == "members" then self.members()
305
+ when op == "cd .." then self.cdback(false)
306
+ when op == "people" then self.people()
283
307
  when op == "teams" #then self.teams()
284
- if @deep==2
308
+ if @deep==ORGS
285
309
  t.show_teams_bs(@client,@config)
286
310
  end
287
311
  when op == "commits" then self.commits()
@@ -290,9 +314,15 @@ class Interface
290
314
  end
291
315
 
292
316
  if opcd[0]=="cd" and opcd[1]!=".."
293
- self.cd(opcd[1])
294
- #else
295
- # self.cdback()
317
+ if opcd[1]=="/"
318
+ self.cdback(true)
319
+ else
320
+ if opcd[1]=="repo" and opcd.size>2
321
+ self.set(opcd[2])
322
+ else
323
+ self.cd(opcd[1])
324
+ end
325
+ end
296
326
  end
297
327
  if opcd[0]=="set"
298
328
  self.set(opcd[1])
@@ -301,52 +331,45 @@ class Interface
301
331
  self.repos()
302
332
  end
303
333
  if opcd[0]=="repos" and opcd.size>1
304
- case
305
- when @deep==1
306
- r.show_repos(@client,@config,1,opcd[1])
307
- when @deep==2
308
- r.show_repos(@client,@config,2,opcd[1])
309
- when @deep==3
310
- r.show_repos(@client,@config,3,opcd[1])
311
- end
334
+ r.show_repos(@client,@config,@deep,opcd[1])
312
335
  end
313
336
  if opcd[0]=="add_team_member"
314
337
  t.add_to_team(@client,@config,opcd[1])
315
338
  end
316
- if opcd[0]=="create_team" and opcd.size==2
339
+ if opcd[0]=="new_team" and opcd.size==2
317
340
  t.create_team(@client,@config,opcd[1])
318
341
  @teamlist=t.read_teamlist(@client,@config)
319
342
  self.add_history_str(1,@teamlist)
320
343
  end
321
- if opcd[0]=="delete_team"
344
+ if opcd[0]=="rm_team"
322
345
  t.delete_team(@client,@teamlist[opcd[1]])
323
346
  self.quit_history(@teamlist[opcd[1]])
324
347
  @teamlist=t.read_teamlist(@client,@config)
325
348
  self.add_history_str(1,@teamlist)
326
349
  end
327
- if opcd[0]=="create_team" and opcd.size>2
350
+ if opcd[0]=="new_team" and opcd.size>2
328
351
  t.create_team_with_members(@client,@config,opcd[1],opcd[2..opcd.size])
329
352
  @teamlist=t.read_teamlist(@client,@config)
330
353
  self.add_history_str(1,@teamlist)
331
354
  end
332
- if opcd[0]=="create_repository" and opcd.size==2
355
+ if opcd[0]=="new_repository" and opcd.size==2
333
356
  r.create_repository(@client,@config,opcd[1],@deep)
334
357
  end
335
- if opcd[0]=="create_repository" and opcd.size>2
358
+ if opcd[0]=="new_assignment" and opcd.size>2
336
359
  case
337
- when @deep==2
360
+ when @deep==ORGS
338
361
  r.create_repository_by_teamlist(@client,@config,opcd[1],opcd[2,opcd.size],self.get_teamlist(opcd[2,opcd.size]))
339
362
  end
340
363
  end
341
364
 
342
- if opcd[0]=="clone_repo" and opcd.size==2
365
+ if opcd[0]=="clone" and opcd.size==2
343
366
  r.clone_repo(@client,@config,opcd[1],@deep)
344
367
  end
345
368
  if op.match(/^!/)
346
369
  op=op.split("!")
347
370
  s.execute_bash(op[1])
348
371
  end
349
- if opcd[0]=="clone_repo" and opcd.size>2
372
+ if opcd[0]=="clone" and opcd.size>2
350
373
  #r.clone_repo(@client,@config,opcd[1])
351
374
  end
352
375
  end
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ghedsh
2
- VERSION='1.1.10'
2
+ VERSION='1.1.11'
3
3
  end
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.10
4
+ version: 1.1.11
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-27 00:00:00.000000000 Z
12
+ date: 2016-05-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: octokit