github_cli 0.5.9 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -0
- data/CHANGELOG.md +12 -1
- data/Gemfile.lock +12 -10
- data/README.md +18 -0
- data/features/authorization.feature +53 -0
- data/features/blob.feature +1 -1
- data/features/download.feature +13 -11
- data/features/gist.feature +9 -1
- data/features/label.feature +11 -12
- data/features/member.feature +5 -4
- data/features/merging.feature +5 -4
- data/features/organization.feature +5 -4
- data/features/repository.feature +9 -1
- data/features/search.feature +5 -4
- data/github_cli.gemspec +1 -1
- data/lib/github_cli/api.rb +56 -49
- data/lib/github_cli/apis/assignee.rb +6 -6
- data/lib/github_cli/apis/authorization.rb +5 -5
- data/lib/github_cli/apis/blob.rb +6 -6
- data/lib/github_cli/apis/collaborator.rb +12 -12
- data/lib/github_cli/apis/commit.rb +6 -6
- data/lib/github_cli/apis/content.rb +9 -9
- data/lib/github_cli/apis/download.rb +15 -15
- data/lib/github_cli/apis/email.rb +9 -9
- data/lib/github_cli/apis/event.rb +24 -24
- data/lib/github_cli/apis/follower.rb +16 -15
- data/lib/github_cli/apis/fork.rb +6 -6
- data/lib/github_cli/apis/gist.rb +31 -30
- data/lib/github_cli/apis/hook.rb +6 -6
- data/lib/github_cli/apis/issue.rb +12 -12
- data/lib/github_cli/apis/key.rb +15 -15
- data/lib/github_cli/apis/label.rb +24 -26
- data/lib/github_cli/apis/member.rb +15 -27
- data/lib/github_cli/apis/merging.rb +3 -3
- data/lib/github_cli/apis/milestone.rb +15 -15
- data/lib/github_cli/apis/notification.rb +18 -18
- data/lib/github_cli/apis/organization.rb +9 -9
- data/lib/github_cli/apis/pull_request.rb +24 -24
- data/lib/github_cli/apis/reference.rb +15 -15
- data/lib/github_cli/apis/repository.rb +13 -12
- data/lib/github_cli/apis/search.rb +12 -12
- data/lib/github_cli/apis/starring.rb +15 -15
- data/lib/github_cli/apis/status.rb +6 -6
- data/lib/github_cli/apis/tag.rb +6 -6
- data/lib/github_cli/apis/team.rb +39 -39
- data/lib/github_cli/apis/tree.rb +6 -6
- data/lib/github_cli/apis/user.rb +9 -9
- data/lib/github_cli/apis/watching.rb +15 -15
- data/lib/github_cli/cli.rb +24 -16
- data/lib/github_cli/commands/assignees.rb +8 -2
- data/lib/github_cli/commands/authorizations.rb +10 -13
- data/lib/github_cli/commands/blobs.rb +9 -3
- data/lib/github_cli/commands/collaborators.rb +16 -4
- data/lib/github_cli/commands/commits.rb +11 -6
- data/lib/github_cli/commands/contents.rb +9 -6
- data/lib/github_cli/commands/downloads.rb +30 -6
- data/lib/github_cli/commands/emails.rb +12 -3
- data/lib/github_cli/commands/events.rb +30 -8
- data/lib/github_cli/commands/followers.rb +20 -5
- data/lib/github_cli/commands/forks.rb +6 -4
- data/lib/github_cli/commands/gists.rb +39 -12
- data/lib/github_cli/commands/hooks.rb +1 -1
- data/lib/github_cli/commands/issues.rb +15 -4
- data/lib/github_cli/commands/keys.rb +20 -5
- data/lib/github_cli/commands/labels.rb +53 -14
- data/lib/github_cli/commands/members.rb +28 -9
- data/lib/github_cli/commands/merging.rb +3 -2
- data/lib/github_cli/commands/milestones.rb +27 -15
- data/lib/github_cli/commands/notifications.rb +19 -11
- data/lib/github_cli/commands/organizations.rb +24 -5
- data/lib/github_cli/commands/pull_requests.rb +30 -8
- data/lib/github_cli/commands/references.rb +17 -5
- data/lib/github_cli/commands/repositories.rb +6 -4
- data/lib/github_cli/commands/search.rb +24 -6
- data/lib/github_cli/commands/starring.rb +19 -5
- data/lib/github_cli/commands/statuses.rb +7 -3
- data/lib/github_cli/commands/tags.rb +7 -3
- data/lib/github_cli/commands/teams.rb +52 -17
- data/lib/github_cli/commands/trees.rb +6 -2
- data/lib/github_cli/commands/users.rb +9 -3
- data/lib/github_cli/commands/watching.rb +19 -5
- data/lib/github_cli/vendor/thor/actions/directory.rb +2 -0
- data/lib/github_cli/vendor/thor/actions/empty_directory.rb +3 -19
- data/lib/github_cli/vendor/thor/actions/file_manipulation.rb +4 -1
- data/lib/github_cli/vendor/thor/actions.rb +1 -1
- data/lib/github_cli/vendor/thor/base.rb +20 -18
- data/lib/github_cli/vendor/thor/command.rb +1 -1
- data/lib/github_cli/vendor/thor/error.rb +0 -4
- data/lib/github_cli/vendor/thor/group.rb +4 -9
- data/lib/github_cli/vendor/thor/runner.rb +1 -1
- data/lib/github_cli/vendor/thor/shell/basic.rb +25 -7
- data/lib/github_cli/vendor/thor/version.rb +1 -1
- data/lib/github_cli/vendor/thor.rb +17 -2
- data/lib/github_cli/version.rb +1 -1
- data/spec/github_cli/api/configure_spec.rb +50 -0
- data/spec/github_cli/api/github_api_spec.rb +19 -0
- data/spec/github_cli/commands/assignees_spec.rb +1 -1
- data/spec/github_cli/commands/blobs_spec.rb +1 -1
- data/spec/github_cli/commands/collaborators_spec.rb +1 -1
- data/spec/github_cli/commands/commits_spec.rb +1 -1
- data/spec/github_cli/commands/contents_spec.rb +1 -1
- data/spec/github_cli/commands/downloads_spec.rb +35 -0
- data/spec/github_cli/commands/emails_spec.rb +1 -1
- data/spec/github_cli/commands/events_spec.rb +1 -1
- data/spec/github_cli/commands/followers_spec.rb +1 -1
- data/spec/github_cli/commands/forks_spec.rb +1 -1
- data/spec/github_cli/commands/gists_spec.rb +6 -1
- data/spec/github_cli/commands/issues_spec.rb +1 -1
- data/spec/github_cli/commands/keys_spec.rb +1 -1
- data/spec/github_cli/commands/labels_spec.rb +13 -3
- data/spec/github_cli/commands/members_spec.rb +46 -0
- data/spec/github_cli/commands/merging_spec.rb +1 -1
- data/spec/github_cli/commands/milestones_spec.rb +1 -1
- data/spec/github_cli/commands/notifications_spec.rb +1 -1
- data/spec/github_cli/commands/organizations_spec.rb +30 -0
- data/spec/github_cli/commands/pull_requests_spec.rb +1 -1
- data/spec/github_cli/commands/references_spec.rb +1 -1
- data/spec/github_cli/commands/repositories_spec.rb +5 -0
- data/spec/github_cli/commands/starring_spec.rb +1 -1
- data/spec/github_cli/commands/statuses_spec.rb +1 -1
- data/spec/github_cli/commands/tags_spec.rb +1 -1
- data/spec/github_cli/commands/teams_spec.rb +1 -1
- data/spec/github_cli/commands/trees_spec.rb +1 -1
- data/spec/github_cli/commands/users_spec.rb +1 -1
- data/spec/github_cli/commands/watching_spec.rb +1 -1
- metadata +27 -17
- data/spec/github_cli/api_spec.rb +0 -19
data/lib/github_cli/apis/team.rb
CHANGED
@@ -5,81 +5,81 @@ module GithubCLI
|
|
5
5
|
|
6
6
|
class << self
|
7
7
|
|
8
|
-
def all(org, params,
|
9
|
-
output
|
10
|
-
github_api.orgs.teams.list org, params
|
8
|
+
def all(org, params, options)
|
9
|
+
output options do
|
10
|
+
github_api(options).orgs.teams.list org, params
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
def get(id, params,
|
15
|
-
output
|
16
|
-
github_api.orgs.teams.get id, params
|
14
|
+
def get(id, params, options)
|
15
|
+
output options do
|
16
|
+
github_api(options).orgs.teams.get id, params
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
def create(org, params,
|
21
|
-
output
|
22
|
-
github_api.orgs.teams.create org, params
|
20
|
+
def create(org, params, options)
|
21
|
+
output options do
|
22
|
+
github_api(options).orgs.teams.create org, params
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
def edit(id, params,
|
27
|
-
output
|
28
|
-
github_api.orgs.teams.edit id, params
|
26
|
+
def edit(id, params, options)
|
27
|
+
output options do
|
28
|
+
github_api(options).orgs.teams.edit id, params
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
def delete(id, params,
|
33
|
-
output
|
34
|
-
github_api.orgs.teams.delete id, params
|
32
|
+
def delete(id, params, options)
|
33
|
+
output options do
|
34
|
+
github_api(options).orgs.teams.delete id, params
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
def all_member(id, params,
|
39
|
-
output
|
40
|
-
github_api.orgs.teams.list_members id, params
|
38
|
+
def all_member(id, params, options)
|
39
|
+
output options do
|
40
|
+
github_api(options).orgs.teams.list_members id, params
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
def member(id, user, params,
|
45
|
-
output
|
46
|
-
github_api.orgs.teams.team_member? id, user, params
|
44
|
+
def member(id, user, params, options)
|
45
|
+
output options do
|
46
|
+
github_api(options).orgs.teams.team_member? id, user, params
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
def add_member(id, user, params,
|
51
|
-
output
|
52
|
-
github_api.orgs.teams.add_member id, user, params
|
50
|
+
def add_member(id, user, params, options)
|
51
|
+
output options do
|
52
|
+
github_api(options).orgs.teams.add_member id, user, params
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
def remove_member(id, user, params,
|
57
|
-
output
|
58
|
-
github_api.orgs.teams.remove_member id, user, params
|
56
|
+
def remove_member(id, user, params, options)
|
57
|
+
output options do
|
58
|
+
github_api(options).orgs.teams.remove_member id, user, params
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
def all_repo(id, params,
|
63
|
-
output
|
64
|
-
github_api.orgs.teams.list_repos id, params
|
62
|
+
def all_repo(id, params, options)
|
63
|
+
output options do
|
64
|
+
github_api(options).orgs.teams.list_repos id, params
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
-
def repo(id, user, repo, params,
|
69
|
-
output
|
70
|
-
github_api.orgs.teams.team_repo? id, user, repo, params
|
68
|
+
def repo(id, user, repo, params, options)
|
69
|
+
output options do
|
70
|
+
github_api(options).orgs.teams.team_repo? id, user, repo, params
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
-
def add_repo(id, user, repo, params,
|
75
|
-
output
|
76
|
-
github_api.orgs.teams.add_repo id, user, repo, params
|
74
|
+
def add_repo(id, user, repo, params, options)
|
75
|
+
output options do
|
76
|
+
github_api(options).orgs.teams.add_repo id, user, repo, params
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
def remove_repo(id, user, repo, params,
|
81
|
-
output
|
82
|
-
github_api.orgs.teams.remove_repo id, user, repo, params
|
80
|
+
def remove_repo(id, user, repo, params, options)
|
81
|
+
output options do
|
82
|
+
github_api(options).orgs.teams.remove_repo id, user, repo, params
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
data/lib/github_cli/apis/tree.rb
CHANGED
@@ -5,15 +5,15 @@ module GithubCLI
|
|
5
5
|
|
6
6
|
class << self
|
7
7
|
|
8
|
-
def get(user, repo, sha, params,
|
9
|
-
output
|
10
|
-
github_api.git_data.trees.get user, repo, sha, params
|
8
|
+
def get(user, repo, sha, params, options)
|
9
|
+
output options do
|
10
|
+
github_api(options).git_data.trees.get user, repo, sha, params
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
def create(user, repo, params,
|
15
|
-
output
|
16
|
-
github_api.git_data.trees.create user, repo, params
|
14
|
+
def create(user, repo, params, options)
|
15
|
+
output options do
|
16
|
+
github_api(options).git_data.trees.create user, repo, params
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
data/lib/github_cli/apis/user.rb
CHANGED
@@ -5,21 +5,21 @@ module GithubCLI
|
|
5
5
|
|
6
6
|
class << self
|
7
7
|
|
8
|
-
def all(params,
|
9
|
-
output
|
10
|
-
github_api.users.all params
|
8
|
+
def all(params, options)
|
9
|
+
output options do
|
10
|
+
github_api(options).users.all params
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
def get(params,
|
15
|
-
output
|
16
|
-
github_api.users.get params
|
14
|
+
def get(params, options)
|
15
|
+
output options do
|
16
|
+
github_api(options).users.get params
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
def update(params,
|
21
|
-
output
|
22
|
-
github_api.users.update params
|
20
|
+
def update(params, options)
|
21
|
+
output options do
|
22
|
+
github_api(options).users.update params
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -5,33 +5,33 @@ module GithubCLI
|
|
5
5
|
|
6
6
|
class << self
|
7
7
|
|
8
|
-
def list(user, repo, params,
|
9
|
-
output
|
10
|
-
github_api.activity.watching.list user, repo, params
|
8
|
+
def list(user, repo, params, options)
|
9
|
+
output options do
|
10
|
+
github_api(options).activity.watching.list user, repo, params
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
def watched(params,
|
15
|
-
output
|
16
|
-
github_api.activity.watching.watched params
|
14
|
+
def watched(params, options)
|
15
|
+
output options do
|
16
|
+
github_api(options).activity.watching.watched params
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
def watching?(user, repo, params,
|
21
|
-
output
|
22
|
-
github_api.activity.watching.watching? user, repo, params
|
20
|
+
def watching?(user, repo, params, options)
|
21
|
+
output options do
|
22
|
+
github_api(options).activity.watching.watching? user, repo, params
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
def start(user, repo, params,
|
27
|
-
output
|
28
|
-
github_api.activity.watching.watch user, repo, params
|
26
|
+
def start(user, repo, params, options)
|
27
|
+
output options do
|
28
|
+
github_api(options).activity.watching.watch user, repo, params
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
def stop(user, repo, params,
|
33
|
-
output
|
34
|
-
github_api.activity.watching.unwatch user, repo, params
|
32
|
+
def stop(user, repo, params, options)
|
33
|
+
output options do
|
34
|
+
github_api(options).activity.watching.unwatch user, repo, params
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
data/lib/github_cli/cli.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
module GithubCLI
|
4
|
+
|
5
|
+
# Main command line interface
|
4
6
|
class CLI < Thor
|
5
7
|
include Thor::Actions
|
6
8
|
require 'github_cli/subcommands'
|
@@ -58,6 +60,7 @@ module GithubCLI
|
|
58
60
|
'user.repo' => nil,
|
59
61
|
'user.org' => nil,
|
60
62
|
'core.adapter' => :net_http,
|
63
|
+
'core.site' => 'https://github.com',
|
61
64
|
'core.endpoint' => 'https://api.github.com',
|
62
65
|
'core.ssl' => nil,
|
63
66
|
'core.mime' => :json,
|
@@ -65,7 +68,8 @@ module GithubCLI
|
|
65
68
|
'core.pager' => 'less',
|
66
69
|
'core.no-pager' => false,
|
67
70
|
'core.no-color' => false,
|
68
|
-
'core.
|
71
|
+
'core.quiet' => false,
|
72
|
+
'core.format' => :table,
|
69
73
|
'core.auto_pagination' => false,
|
70
74
|
'core.aliases' => nil,
|
71
75
|
}
|
@@ -74,6 +78,12 @@ module GithubCLI
|
|
74
78
|
|
75
79
|
option :local, :type => :boolean, :default => false, :aliases => "-l",
|
76
80
|
:desc => 'Modify local configuration file, otherwise a global configuration file is changed.'
|
81
|
+
option :scopes, :type => :array, :banner => "user public_repo repo...",
|
82
|
+
:desc => "A list of scopes that this authorization is in."
|
83
|
+
option :note, :type => :string,
|
84
|
+
:desc => "A note to remind you what the OAuth token is for."
|
85
|
+
option :note_url, :type => :string,
|
86
|
+
:desc => "A URL to remind you what the OAuth token is for."
|
77
87
|
desc 'authorize', 'Add user authentication token'
|
78
88
|
long_desc <<-DESC
|
79
89
|
Create authorization token for a user named <username> Save user credentials to the .githubrc file.\n
|
@@ -90,14 +100,12 @@ module GithubCLI
|
|
90
100
|
params['note_url'] = options[:note_url] || 'https://github.com/peter-murach/github_cli'
|
91
101
|
global_options[:params] = params
|
92
102
|
# Need to configure client with login and password
|
93
|
-
print 'OPTIONS '
|
94
|
-
p options
|
95
103
|
login = ask("login: ")
|
96
104
|
password = ask("password: ")
|
97
105
|
|
98
|
-
global_options['login']
|
106
|
+
global_options['login'] = login
|
99
107
|
global_options['password'] = password
|
100
|
-
global_options['quiet']
|
108
|
+
global_options['quiet'] = options[:quiet]
|
101
109
|
|
102
110
|
res = self.invoke("auth:create", [], global_options)
|
103
111
|
token = res.body['token']
|
@@ -109,7 +117,7 @@ module GithubCLI
|
|
109
117
|
config['user.token'] = token
|
110
118
|
|
111
119
|
GithubCLI.ui.warn <<-EOF
|
112
|
-
Your #{GithubCLI.config.location} has been overwritten!
|
120
|
+
Your #{GithubCLI.config.location} configuration file has been overwritten!
|
113
121
|
EOF
|
114
122
|
end
|
115
123
|
|
@@ -120,6 +128,10 @@ module GithubCLI
|
|
120
128
|
GithubCLI.ui.info me
|
121
129
|
end
|
122
130
|
|
131
|
+
option :force, :type => :boolean, :default => false, :aliases => "-f",
|
132
|
+
:banner => "Overwrite configuration file. "
|
133
|
+
option :local, :type => :boolean, :default => false, :aliases => "-l",
|
134
|
+
:desc => 'Create local configuration file, otherwise a global configuration file in user home is created.'
|
123
135
|
desc 'init', 'Create a configuration file or overwirte existing one'
|
124
136
|
long_desc <<-DESC
|
125
137
|
Initializes a configuration file where you can set default options for
|
@@ -129,10 +141,6 @@ module GithubCLI
|
|
129
141
|
override the bult-in defaults and allow you to save typing commonly used
|
130
142
|
command line options.
|
131
143
|
DESC
|
132
|
-
option :force, :type => :boolean, :default => false, :aliases => "-f",
|
133
|
-
:banner => "Overwrite configuration file. "
|
134
|
-
option :local, :type => :boolean, :default => false, :aliases => "-l",
|
135
|
-
:desc => 'Create local configuration file, otherwise a global configuration file in user home is created.'
|
136
144
|
def init(filename=nil)
|
137
145
|
config_filename = filename ? filename : options[:filename]
|
138
146
|
config = GithubCLI.config
|
@@ -148,6 +156,12 @@ module GithubCLI
|
|
148
156
|
GithubCLI.ui.confirm "Writing new configuration file to #{GithubCLI.config.path}"
|
149
157
|
end
|
150
158
|
|
159
|
+
option :local, :type => :boolean, :default => false,
|
160
|
+
:desc => 'use local config file'
|
161
|
+
option :list, :type => :boolean, :default => false, :aliases => '-l',
|
162
|
+
:desc => 'list all'
|
163
|
+
option :edit, :type => :boolean, :default => false, :aliases => '-e',
|
164
|
+
:desc => 'opens an editor'
|
151
165
|
desc 'config', 'Get and set GitHub configuration options'
|
152
166
|
long_desc <<-DESC
|
153
167
|
You can query/set options with this command. The name is actually a hash key
|
@@ -158,12 +172,6 @@ module GithubCLI
|
|
158
172
|
There two types of config files, global and project specific. When modifying
|
159
173
|
options ensure that you modifying the correct config.
|
160
174
|
DESC
|
161
|
-
option :local, :type => :boolean, :default => false,
|
162
|
-
:desc => 'use local config file'
|
163
|
-
option :list, :type => :boolean, :default => false, :aliases => '-l',
|
164
|
-
:desc => 'list all'
|
165
|
-
option :edit, :type => :boolean, :default => false, :aliases => '-e',
|
166
|
-
:desc => 'opens an editor'
|
167
175
|
def config(*args)
|
168
176
|
name, value = args.shift, args.shift
|
169
177
|
GithubCLI.config.location = options[:local] ? 'local' : 'global'
|
@@ -10,12 +10,18 @@ module GithubCLI
|
|
10
10
|
Lists all the available assignees (owner + collaborators) to which issues may be assigned
|
11
11
|
DESC
|
12
12
|
def list(user, repo)
|
13
|
-
|
13
|
+
global_options = options.dup
|
14
|
+
params = options[:params].dup
|
15
|
+
Util.hash_without!(global_options, params.keys + ['params'])
|
16
|
+
Assignee.all user, repo, params, global_options
|
14
17
|
end
|
15
18
|
|
16
19
|
desc 'check <user> <repo> <assignee>', 'Check if <assignee> is assigned to <repo>'
|
17
20
|
def check(user, repo, assignee)
|
18
|
-
|
21
|
+
global_options = options.dup
|
22
|
+
params = options[:params].dup
|
23
|
+
Util.hash_without!(global_options, params.keys + ['params'])
|
24
|
+
Assignee.check user, repo, assignee, params, global_options
|
19
25
|
end
|
20
26
|
|
21
27
|
end # Assignees
|
@@ -11,8 +11,8 @@ module GithubCLI
|
|
11
11
|
DESC
|
12
12
|
def list
|
13
13
|
global_options = options.dup
|
14
|
-
params =
|
15
|
-
Util.hash_without!(global_options,
|
14
|
+
params = options[:params].dup
|
15
|
+
Util.hash_without!(global_options, params.keys + ['params'])
|
16
16
|
Authorization.all params, global_options
|
17
17
|
end
|
18
18
|
|
@@ -22,8 +22,8 @@ module GithubCLI
|
|
22
22
|
DESC
|
23
23
|
def get(id)
|
24
24
|
global_options = options.dup
|
25
|
-
params =
|
26
|
-
Util.hash_without!(global_options,
|
25
|
+
params = options[:params].dup
|
26
|
+
Util.hash_without!(global_options, params.keys + ['params'])
|
27
27
|
Authorization.get id, params, global_options
|
28
28
|
end
|
29
29
|
|
@@ -45,12 +45,11 @@ module GithubCLI
|
|
45
45
|
DESC
|
46
46
|
def create
|
47
47
|
global_options = options.dup
|
48
|
-
params =
|
48
|
+
params = options[:params].dup
|
49
49
|
params['scopes'] = options[:scopes] if options[:scopes]
|
50
50
|
params['note'] = options[:note] if options[:note]
|
51
51
|
params['note_url'] = options[:note_url] if options[:note_url]
|
52
|
-
|
53
|
-
Util.hash_without!(global_options, %w[ params scopes note note_url])
|
52
|
+
Util.hash_without!(global_options, params.keys + ['params'])
|
54
53
|
|
55
54
|
Authorization.create params, global_options
|
56
55
|
end
|
@@ -77,15 +76,13 @@ module GithubCLI
|
|
77
76
|
DESC
|
78
77
|
def update(id)
|
79
78
|
global_options = options.dup
|
80
|
-
params
|
79
|
+
params = options[:params].dup
|
81
80
|
params['scopes'] = options[:scopes] if options[:scopes]
|
82
81
|
params['add_scopes'] = options[:add_scopes] if options[:add_scopes]
|
83
82
|
params['remove_scopes'] = options[:remove_scopes] if options[:remove_scopes]
|
84
83
|
params['note'] = options[:note] if options[:note]
|
85
84
|
params['note_url'] = options[:note_url] if options[:note_url]
|
86
|
-
|
87
|
-
Util.hash_without!(global_options,
|
88
|
-
%w[ params scopes add_scopes remove_scopes note note_url])
|
85
|
+
Util.hash_without!(global_options, params.keys + ['params'])
|
89
86
|
|
90
87
|
Authorization.update id, params, global_options
|
91
88
|
end
|
@@ -93,8 +90,8 @@ module GithubCLI
|
|
93
90
|
desc 'delete <id>', 'Delete an authorization'
|
94
91
|
def delete(id)
|
95
92
|
global_options = options.dup
|
96
|
-
params
|
97
|
-
Util.hash_without!(global_options,
|
93
|
+
params = options[:params].dup
|
94
|
+
Util.hash_without!(global_options, params.keys + ['params'])
|
98
95
|
Authorization.delete id, params, global_options
|
99
96
|
end
|
100
97
|
|
@@ -7,7 +7,11 @@ module GithubCLI
|
|
7
7
|
|
8
8
|
desc 'get <user> <repo> <sha>', 'Get a Blob'
|
9
9
|
def get(user, repo, sha)
|
10
|
-
|
10
|
+
global_options = options.dup
|
11
|
+
params = options[:params].dup
|
12
|
+
Util.hash_without!(global_options, params.keys + ['params'])
|
13
|
+
|
14
|
+
Blob.get user, repo, sha, params, global_options
|
11
15
|
end
|
12
16
|
|
13
17
|
option :content, :type => :string
|
@@ -21,11 +25,13 @@ module GithubCLI
|
|
21
25
|
encoding - String containing encoding utf-8 or base64
|
22
26
|
DESC
|
23
27
|
def create(user, repo)
|
28
|
+
global_options = options.dup
|
24
29
|
params = options[:params].dup
|
25
|
-
params['content']
|
30
|
+
params['content'] = options[:content] if options[:content]
|
26
31
|
params['encoding'] = options[:encoding] if options[:encoding]
|
32
|
+
Util.hash_without!(global_options, params.keys + ['params'])
|
27
33
|
|
28
|
-
Blob.create user, repo, params,
|
34
|
+
Blob.create user, repo, params, global_options
|
29
35
|
end
|
30
36
|
|
31
37
|
end # Blobs
|
@@ -7,22 +7,34 @@ module GithubCLI
|
|
7
7
|
|
8
8
|
desc 'list <owner> <repo>', 'Lists collaborators'
|
9
9
|
def list(owner, repo)
|
10
|
-
|
10
|
+
global_options = options.dup
|
11
|
+
params = options[:params].dup
|
12
|
+
Util.hash_without!(global_options, params.keys + ['params'])
|
13
|
+
Collaborator.all owner, repo, params, global_options
|
11
14
|
end
|
12
15
|
|
13
16
|
desc 'add <owner> <repo> <user>', 'Add a collaborator'
|
14
17
|
def add(owner, repo, user)
|
15
|
-
|
18
|
+
global_options = options.dup
|
19
|
+
params = options[:params].dup
|
20
|
+
Util.hash_without!(global_options, params.keys + ['params'])
|
21
|
+
Collaborator.add owner, repo, user, params, global_options
|
16
22
|
end
|
17
23
|
|
18
24
|
desc 'collab <owner> <repo> <user>', 'Checks if user is a collaborator on a given repo'
|
19
25
|
def collab(owner, repo, user)
|
20
|
-
|
26
|
+
global_options = options.dup
|
27
|
+
params = options[:params].dup
|
28
|
+
Util.hash_without!(global_options, params.keys + ['params'])
|
29
|
+
Collaborator.collaborator? owner, repo, user, params, global_options
|
21
30
|
end
|
22
31
|
|
23
32
|
desc 'remove <owner> <repo> <user>', 'Remove a collaborator'
|
24
33
|
def remove(owner, repo, user)
|
25
|
-
|
34
|
+
global_options = options.dup
|
35
|
+
params = options[:params].dup
|
36
|
+
Util.hash_without!(global_options, params.keys + ['params'])
|
37
|
+
Collaborator.remove owner, repo, user, params, global_options
|
26
38
|
end
|
27
39
|
|
28
40
|
end # Collaborators
|
@@ -7,7 +7,10 @@ module GithubCLI
|
|
7
7
|
|
8
8
|
desc 'get <user> <repo> <sha>', 'Get a Commit'
|
9
9
|
def get(user, repo, sha)
|
10
|
-
|
10
|
+
global_options = options.dup
|
11
|
+
params = options[:params].dup
|
12
|
+
Util.hash_without!(global_options, params.keys + ['params'])
|
13
|
+
Commit.get user, repo, sha, params, global_options
|
11
14
|
end
|
12
15
|
|
13
16
|
desc 'create <user> <repo>', 'Create a Commit'
|
@@ -40,13 +43,15 @@ module GithubCLI
|
|
40
43
|
committer.date - Timestamp of when this commit was committed
|
41
44
|
DESC
|
42
45
|
def create(user, repo)
|
46
|
+
global_options = options.dup
|
43
47
|
params = options[:params].dup
|
44
|
-
params['message'] = options[:message]
|
45
|
-
params['tree'] = options[:tree]
|
46
|
-
params['parents'] = options[:parents]
|
47
|
-
params['author'] = options[:author]
|
48
|
+
params['message'] = options[:message] if options[:message]
|
49
|
+
params['tree'] = options[:tree] if options[:tree]
|
50
|
+
params['parents'] = options[:parents] if options[:parents]
|
51
|
+
params['author'] = options[:author] if options[:author]
|
48
52
|
params['committer'] = options[:committer] if options[:committer]
|
49
|
-
|
53
|
+
Util.hash_without!(global_options, params.keys + ['params'])
|
54
|
+
Commit.create user, repo, params, global_options
|
50
55
|
end
|
51
56
|
|
52
57
|
end # Commit
|
@@ -16,10 +16,11 @@ module GithubCLI
|
|
16
16
|
ref - Optional string - The String name of the Commit/Branch/Tag. Defaults to master.
|
17
17
|
DESC
|
18
18
|
def get(user, repo, path)
|
19
|
+
global_options = options.dup
|
19
20
|
params = options[:params].dup
|
20
21
|
params['ref'] = options[:ref] if options[:ref]
|
21
|
-
|
22
|
-
Content.get user, repo, path, params,
|
22
|
+
Util.hash_without!(global_options, params.keys + ['params'])
|
23
|
+
Content.get user, repo, path, params, global_options
|
23
24
|
end
|
24
25
|
|
25
26
|
option :ref, :type => :string,
|
@@ -31,10 +32,11 @@ module GithubCLI
|
|
31
32
|
ref - Optional string - The String name of the Commit/Branch/Tag. Defaults to master.
|
32
33
|
DESC
|
33
34
|
def readme(user, repo)
|
35
|
+
global_options = options.dup
|
34
36
|
params = options[:params].dup
|
35
37
|
params['ref'] = options[:ref] if options[:ref]
|
36
|
-
|
37
|
-
Content.readme user, repo, params,
|
38
|
+
Util.hash_without!(global_options, params.keys + ['params'])
|
39
|
+
Content.readme user, repo, params, global_options
|
38
40
|
end
|
39
41
|
|
40
42
|
option :ref, :type => :string,
|
@@ -56,11 +58,12 @@ module GithubCLI
|
|
56
58
|
ref - Optional string - valid Git reference, defaults to master\n
|
57
59
|
DESC
|
58
60
|
def archive(user, repo)
|
61
|
+
global_options = options.dup
|
59
62
|
params = options[:params].dup
|
60
63
|
params['ref'] = options[:ref] if options[:ref]
|
61
64
|
params['archive_format'] = options[:archive_format] if options[:archive_format]
|
62
|
-
|
63
|
-
Content.archive user, repo, params,
|
65
|
+
Util.hash_without!(global_options, params.keys + ['params'])
|
66
|
+
Content.archive user, repo, params, global_options
|
64
67
|
end
|
65
68
|
|
66
69
|
end # Contents
|
@@ -7,14 +7,26 @@ module GithubCLI
|
|
7
7
|
|
8
8
|
desc 'list <user> <repo>', 'Lists downloads'
|
9
9
|
def list(user, repo)
|
10
|
-
|
10
|
+
global_options = options.dup
|
11
|
+
params = options[:params].dup
|
12
|
+
Util.hash_without!(global_options, params.keys + ['params'])
|
13
|
+
Download.all user, repo, params, global_options
|
11
14
|
end
|
12
15
|
|
13
16
|
desc 'get <user> <repo> <id>', 'Get a download'
|
14
17
|
def get(user, repo, id)
|
15
|
-
|
18
|
+
global_options = options.dup
|
19
|
+
params = options[:params].dup
|
20
|
+
Util.hash_without!(global_options, params.keys + ['params'])
|
21
|
+
Download.get user, repo, id, params, global_options
|
16
22
|
end
|
17
23
|
|
24
|
+
option :name, :type => :string, :required => true,
|
25
|
+
:desc => 'name of the file that is being created.'
|
26
|
+
option :size, :type => :numeric, :required => true,
|
27
|
+
:desc => 'size of file in bytes'
|
28
|
+
option :desc, :type => :string
|
29
|
+
option :type, :type => :string
|
18
30
|
desc 'create <user> <repo>', 'Create a new download resource'
|
19
31
|
long_desc <<-DESC
|
20
32
|
Creating a new download is a two step process.
|
@@ -30,13 +42,20 @@ module GithubCLI
|
|
30
42
|
content_type - Optional string \n
|
31
43
|
DESC
|
32
44
|
def create(user, repo)
|
33
|
-
|
45
|
+
global_options = options.dup
|
46
|
+
params = options[:params].dup
|
47
|
+
params['name'] = options[:name]
|
48
|
+
params['size'] = options[:size]
|
49
|
+
params['descritpion'] = options[:desc] if options[:desc]
|
50
|
+
params['content_type'] = options[:type] if options[:type]
|
51
|
+
Util.hash_without!(global_options, params.keys + ['params'])
|
52
|
+
Download.create user, repo, params, global_options
|
34
53
|
end
|
35
54
|
|
36
55
|
desc 'upload <resource> <filename>', 'Upload resource to s3'
|
37
56
|
long_desc <<-DESC
|
38
57
|
Upload a file to Amazon, using the reponse instance from
|
39
|
-
Github::Repos::Downloads#
|
58
|
+
Github::Repos::Downloads#create
|
40
59
|
|
41
60
|
This can be done by passing the response object
|
42
61
|
as an argument to upload method.
|
@@ -47,12 +66,17 @@ module GithubCLI
|
|
47
66
|
filename - Required filename, a path to a file location. \n
|
48
67
|
DESC
|
49
68
|
def upload(resource, filename)
|
50
|
-
|
69
|
+
global_options = options.dup
|
70
|
+
Util.hash_without!(global_options, ['params'])
|
71
|
+
Download.upload resource, filename, global_options
|
51
72
|
end
|
52
73
|
|
53
74
|
desc 'delete <user> <repo> <id>', 'Delete a download'
|
54
75
|
def delete(user, repo, id)
|
55
|
-
|
76
|
+
global_options = options.dup
|
77
|
+
params = options[:params].dup
|
78
|
+
Util.hash_without!(global_options, params.keys + ['params'])
|
79
|
+
Download.delete user, repo, id, params, global_options
|
56
80
|
end
|
57
81
|
|
58
82
|
end # Downloads
|