github_cli 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +21 -0
- data/Gemfile.lock +20 -22
- data/README.md +29 -4
- data/bin/ghc +1 -1
- data/features/download.feature +11 -0
- data/features/email.feature +9 -0
- data/features/errors.feature +10 -0
- data/features/event.feature +14 -0
- data/features/executable.feature +44 -17
- data/features/follower.feature +11 -0
- data/features/fork.feature +13 -0
- data/features/hook.feature +12 -0
- data/features/label.feature +16 -0
- data/features/member.feature +18 -0
- data/features/milestone.feature +11 -0
- data/features/organization.feature +9 -0
- data/features/reference.feature +11 -0
- data/features/repositories.feature +16 -7
- data/features/tag.feature +8 -0
- data/features/team.feature +18 -0
- data/features/tree.feature +8 -0
- data/features/user.feature +8 -0
- data/ghc_logo.png +0 -0
- data/github_cli.gemspec +2 -2
- data/lib/github_cli/api.rb +14 -11
- data/lib/github_cli/apis/follower.rb +40 -0
- data/lib/github_cli/apis/member.rb +52 -0
- data/lib/github_cli/apis/organization.rb +28 -0
- data/lib/github_cli/apis/team.rb +89 -0
- data/lib/github_cli/apis/user.rb +22 -0
- data/lib/github_cli/apis.rb +5 -0
- data/lib/github_cli/cli.rb +11 -4
- data/lib/github_cli/command.rb +40 -28
- data/lib/github_cli/commands/followers.rb +50 -0
- data/lib/github_cli/commands/members.rb +70 -0
- data/lib/github_cli/commands/organizations.rb +42 -0
- data/lib/github_cli/commands/teams.rb +148 -0
- data/lib/github_cli/commands/users.rb +26 -0
- data/lib/github_cli/commands.rb +5 -0
- data/lib/github_cli/editor.rb +27 -0
- data/lib/github_cli/errors.rb +6 -1
- data/lib/github_cli/formatter.rb +47 -0
- data/lib/github_cli/formatters/csv.rb +8 -8
- data/lib/github_cli/formatters/table.rb +237 -11
- data/lib/github_cli/pager.rb +66 -0
- data/lib/github_cli/subcommands.rb +15 -0
- data/lib/github_cli/system.rb +33 -0
- data/lib/github_cli/terminal.rb +60 -30
- data/lib/github_cli/thor_ext.rb +15 -0
- data/lib/github_cli/ui.rb +8 -0
- data/lib/github_cli/util.rb +55 -12
- data/lib/github_cli/version.rb +1 -1
- data/lib/github_cli.rb +3 -0
- data/spec/github_cli/pager_spec.rb +69 -0
- data/spec/github_cli/util_spec.rb +14 -4
- metadata +64 -14
@@ -0,0 +1,28 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module GithubCLI
|
4
|
+
class Organization < API
|
5
|
+
|
6
|
+
class << self
|
7
|
+
|
8
|
+
def list(user, params, format)
|
9
|
+
output format do
|
10
|
+
github_api.orgs.list user, params
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def get(org, params, format)
|
15
|
+
output format do
|
16
|
+
github_api.orgs.get org, params
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def edit(org, params, format)
|
21
|
+
output format do
|
22
|
+
github_api.orgs.edit org, params
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end # Organization
|
28
|
+
end # GithubCLI
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module GithubCLI
|
4
|
+
class Team < API
|
5
|
+
|
6
|
+
class << self
|
7
|
+
|
8
|
+
def all(org, params, format)
|
9
|
+
output format do
|
10
|
+
github_api.orgs.teams.list org, params
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
def get(id, params, format)
|
16
|
+
output format do
|
17
|
+
github_api.orgs.teams.get id, params
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def create(org, params, format)
|
22
|
+
output format do
|
23
|
+
github_api.orgs.teams.create org, params
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def edit(id, params, format)
|
28
|
+
output format do
|
29
|
+
github_api.orgs.teams.edit id, params
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def delete(id, params, format)
|
34
|
+
output format do
|
35
|
+
github_api.orgs.teams.delete id, params
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def all_member(id, params, format)
|
40
|
+
output format do
|
41
|
+
github_api.orgs.teams.list_members id, params
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def member(id, user, params, format)
|
46
|
+
output format do
|
47
|
+
github_api.orgs.teams.team_member? id, user, params
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def add_member(id, user, params, format)
|
52
|
+
output format do
|
53
|
+
github_api.orgs.teams.add_member id, user, params
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def remove_member(id, user, params, format)
|
58
|
+
output format do
|
59
|
+
github_api.orgs.teams.remove_member id, user, params
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def all_repo(id, params, format)
|
64
|
+
output format do
|
65
|
+
github_api.orgs.teams.list_repos id, params
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def repo(id, user, repo, params, format)
|
70
|
+
output format do
|
71
|
+
github_api.orgs.teams.team_repo? id, user, repo, params
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def add_repo(id, user, repo, params, format)
|
76
|
+
output format do
|
77
|
+
github_api.orgs.teams.add_member id, user, repo, params
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def remove_repo(id, user, repo, params, format)
|
82
|
+
output format do
|
83
|
+
github_api.orgs.teams.remove_repo id, user, repo, params
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
end # Team
|
89
|
+
end # GithubCLI
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module GithubCLI
|
4
|
+
class User < API
|
5
|
+
|
6
|
+
class << self
|
7
|
+
|
8
|
+
def get(user, params, format)
|
9
|
+
output format do
|
10
|
+
github_api.users.get params.update(:user => user)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def update(params, format)
|
15
|
+
output format do
|
16
|
+
github_api.users.update params
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end # User
|
22
|
+
end # GithubCLI
|
data/lib/github_cli/apis.rb
CHANGED
@@ -15,18 +15,23 @@ end
|
|
15
15
|
commit
|
16
16
|
download
|
17
17
|
email
|
18
|
+
follower
|
18
19
|
fork
|
19
20
|
gist
|
20
21
|
hook
|
21
22
|
issue
|
22
23
|
key
|
23
24
|
label
|
25
|
+
member
|
24
26
|
milestone
|
27
|
+
organization
|
25
28
|
pull_request
|
26
29
|
reference
|
27
30
|
repository
|
28
31
|
tag
|
32
|
+
team
|
29
33
|
tree
|
34
|
+
user
|
30
35
|
watching
|
31
36
|
].each do |api|
|
32
37
|
require_api api
|
data/lib/github_cli/cli.rb
CHANGED
@@ -10,13 +10,13 @@ module GithubCLI
|
|
10
10
|
the_shell = (options["no-color"] ? Thor::Shell::Basic.new : shell)
|
11
11
|
GithubCLI.ui = UI.new(the_shell)
|
12
12
|
GithubCLi.ui.debug! if options["verbose"]
|
13
|
-
|
13
|
+
options["no-pager"] ? Pager.disable : Pager.enable
|
14
14
|
end
|
15
15
|
|
16
16
|
map "repository" => :repo,
|
17
17
|
"reference" => :ref,
|
18
18
|
"is" => :issue,
|
19
|
-
"
|
19
|
+
"--version" => :version,
|
20
20
|
"ls" => :list
|
21
21
|
|
22
22
|
class_option :config, :type => :string,
|
@@ -26,9 +26,16 @@ module GithubCLI
|
|
26
26
|
:desc => 'Authentication token.',
|
27
27
|
:banner => 'Set authentication token'
|
28
28
|
class_option "no-color", :type => :boolean,
|
29
|
-
:
|
29
|
+
:desc => "Disable colorization in output."
|
30
|
+
class_option "no-pager", :type => :boolean,
|
31
|
+
:desc => "Disable pagination of the output."
|
32
|
+
class_option :pager, :type => :string, :aliases => '-p',
|
33
|
+
:desc => "Command to be used for paging. Command can have options after it i.e. 'less -r'. Defaults to common pagers i.e. less if detected.",
|
34
|
+
:banner => "less, more etc..."
|
30
35
|
class_option :verbose, :type => :boolean,
|
31
|
-
:
|
36
|
+
:desc => "Enable verbose output mode."
|
37
|
+
class_option :version, :type => :boolean,
|
38
|
+
:desc => "Show program version"
|
32
39
|
|
33
40
|
desc 'init', 'Generates a configuration file in your home directory'
|
34
41
|
long_desc <<-DESC
|
data/lib/github_cli/command.rb
CHANGED
@@ -10,7 +10,8 @@ module GithubCLI
|
|
10
10
|
issue label milestone
|
11
11
|
tag tree blob reference commit
|
12
12
|
pull
|
13
|
-
email
|
13
|
+
user email follower
|
14
|
+
org member team
|
14
15
|
event
|
15
16
|
)
|
16
17
|
|
@@ -31,44 +32,55 @@ module GithubCLI
|
|
31
32
|
"all" => :list,
|
32
33
|
"del" => :delete
|
33
34
|
|
35
|
+
class_option :params, :type => :hash, :default => {}, :aliases => '-p',
|
36
|
+
:desc => 'Request parameters e.i per_page:100'
|
37
|
+
|
34
38
|
class_option :format, :type => :string, :aliases => '-f',
|
35
39
|
:default => 'table',
|
36
40
|
:banner => output_formats.keys.join('|'),
|
37
|
-
:desc => "Format of the output"
|
38
|
-
class_option :pager, :type => :boolean, :aliases => '-p',
|
39
|
-
:default => true,
|
40
|
-
:desc => "Determines if the output is paged."
|
41
|
+
:desc => "Format of the output. Type table:h to display table horizontally."
|
41
42
|
|
42
|
-
|
43
|
-
"#{basename} #{task.formatted_usage(self, true, subcommand)}"
|
44
|
-
end
|
43
|
+
class << self
|
45
44
|
|
45
|
+
def banner(task, namespace=true, subcommand=true)
|
46
|
+
"#{basename} #{task.formatted_usage(self, true, subcommand)}"
|
47
|
+
end
|
46
48
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
49
|
+
def all
|
50
|
+
commands = []
|
51
|
+
Thor::Base.subclasses.each do |klass|
|
52
|
+
namespace = extract_namespace(klass)
|
53
|
+
next unless is_api_command?(namespace)
|
54
|
+
namespace = "" if namespace.index API_CLASSES.first
|
53
55
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
56
|
+
klass.tasks.each do |task|
|
57
|
+
next if task.last.name.index HELP_COMMAND
|
58
|
+
commands << Comm.new(namespace,
|
59
|
+
task.last.name,
|
60
|
+
task.last.description,
|
61
|
+
task.last.usage)
|
62
|
+
end
|
60
63
|
end
|
64
|
+
commands
|
61
65
|
end
|
62
|
-
commands
|
63
|
-
end
|
64
66
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
67
|
+
def is_api_command?(klass)
|
68
|
+
return false unless API_CLASSES.include?(klass.to_s)
|
69
|
+
return true
|
70
|
+
end
|
71
|
+
|
72
|
+
def extract_namespace(klass)
|
73
|
+
klass.namespace.split(':').last
|
74
|
+
end
|
75
|
+
|
76
|
+
def command_to_show(command)
|
77
|
+
command_token = Command.all.find do |cmd|
|
78
|
+
end_index = command.index('<').nil? ? -1 : command.index('<')
|
79
|
+
!cmd.namespace.empty? && command[0..end_index].include?(cmd.namespace)
|
80
|
+
end
|
81
|
+
command_token ? command_token.namespace : '<command>'
|
82
|
+
end
|
69
83
|
|
70
|
-
def self.extract_namespace(klass)
|
71
|
-
klass.namespace.split(':').last
|
72
84
|
end
|
73
85
|
|
74
86
|
end # Command
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module GithubCLI
|
4
|
+
class Commands::Followers < Command
|
5
|
+
|
6
|
+
namespace :follower
|
7
|
+
|
8
|
+
desc 'list', "Lists an authenticated user's followers"
|
9
|
+
method_option :user, :type => :string, :aliases => ["-u"],
|
10
|
+
:desc => 'List a <user> followers',
|
11
|
+
:banner => '<user>'
|
12
|
+
method_option :params, :type => :hash, :default => {},
|
13
|
+
:desc => 'Additional request parameters e.i per_page:100'
|
14
|
+
def list
|
15
|
+
Follower.all options[:user], options[:params], options[:format]
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'following', 'List who the authenticated user is following'
|
19
|
+
method_option :user, :type => :string, :aliases => ["-u"],
|
20
|
+
:desc => 'List who a <user> is following',
|
21
|
+
:banner => '<user>'
|
22
|
+
method_option :params, :type => :hash, :default => {},
|
23
|
+
:desc => 'Additional request parameters e.i per_page:100'
|
24
|
+
def following
|
25
|
+
Follower.following options[:user], options[:params], options[:format]
|
26
|
+
end
|
27
|
+
|
28
|
+
desc 'follower <user>', 'Check if you are following a user'
|
29
|
+
method_option :params, :type => :hash, :default => {},
|
30
|
+
:desc => 'Additional request parameters e.i per_page:100'
|
31
|
+
def follower(user)
|
32
|
+
Follower.following? user, options[:params], options[:format]
|
33
|
+
end
|
34
|
+
|
35
|
+
desc 'follow <user>', 'Follow a user'
|
36
|
+
method_option :params, :type => :hash, :default => {},
|
37
|
+
:desc => 'Additional request parameters e.i per_page:100'
|
38
|
+
def follow(user)
|
39
|
+
Follower.follow user, options[:params], options[:format]
|
40
|
+
end
|
41
|
+
|
42
|
+
desc 'unfollow <user>', 'Unfollow a user'
|
43
|
+
method_option :params, :type => :hash, :default => {},
|
44
|
+
:desc => 'Additional request parameters e.i per_page:100'
|
45
|
+
def unfollow(user)
|
46
|
+
Follower.unfollow user, options[:params], options[:format]
|
47
|
+
end
|
48
|
+
|
49
|
+
end # Followers
|
50
|
+
end # GithubCLI
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module GithubCLI
|
4
|
+
class Commands::Members < Command
|
5
|
+
|
6
|
+
namespace :member
|
7
|
+
|
8
|
+
desc 'list <org>', "Lists an organization members"
|
9
|
+
long_desc <<-DESC
|
10
|
+
List all users who are members of an organization. A member is a user
|
11
|
+
that belongs to at least 1 team in the organization.
|
12
|
+
|
13
|
+
If the authenticated user is also a member of this organization then
|
14
|
+
both concealed and public members will be returned.
|
15
|
+
Otherwise only public members are returned.
|
16
|
+
|
17
|
+
Members of an organization can choose to have their membership publicized or not.
|
18
|
+
DESC
|
19
|
+
method_option :public, :type => :boolean, :default => false,
|
20
|
+
:desc => 'List public members'
|
21
|
+
method_option :params, :type => :hash, :default => {},
|
22
|
+
:desc => 'Additional request parameters e.i per_page:100'
|
23
|
+
def list(org)
|
24
|
+
if options[:public]
|
25
|
+
Member.all_public org, options[:params], options[:format]
|
26
|
+
else
|
27
|
+
Member.all org, options[:params], options[:format]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
desc 'member <org> <user>', 'Checks if user is a member of an organization'
|
32
|
+
method_option :public, :type => :boolean, :default => false,
|
33
|
+
:desc => 'Get if a user is a public member of an organization'
|
34
|
+
method_option :params, :type => :hash, :default => {},
|
35
|
+
:desc => 'Additional request parameters e.i per_page:100'
|
36
|
+
def member(org, user)
|
37
|
+
if options[:public]
|
38
|
+
Member.public_member? org, user, options[:params], options[:format]
|
39
|
+
else
|
40
|
+
Member.member? org, user, options[:params], options[:format]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
desc 'delete <org> <user>', 'Remove a member from an organization'
|
45
|
+
long_desc <<-DESC
|
46
|
+
Removing a user from this list will remove them from all teams and they
|
47
|
+
will no longer have any access to the organization’s repositories.
|
48
|
+
DESC
|
49
|
+
method_option :params, :type => :hash, :default => {},
|
50
|
+
:desc => 'Additional request parameters e.i per_page:100'
|
51
|
+
def delete(org, user)
|
52
|
+
Member.delete org, user, options[:params], options[:format]
|
53
|
+
end
|
54
|
+
|
55
|
+
desc 'publicize <org> <user>', "Publicize a user’s membership"
|
56
|
+
method_option :params, :type => :hash, :default => {},
|
57
|
+
:desc => 'Additional request parameters e.i per_page:100'
|
58
|
+
def publicize(org, user)
|
59
|
+
Member.publicize org, user, options[:params], options[:format]
|
60
|
+
end
|
61
|
+
|
62
|
+
desc 'conceal <org> <user>', "Conceal a user’s membership"
|
63
|
+
method_option :params, :type => :hash, :default => {},
|
64
|
+
:desc => 'Additional request parameters e.i per_page:100'
|
65
|
+
def conceal(org, user)
|
66
|
+
Member.conceal org, user, options[:params], options[:format]
|
67
|
+
end
|
68
|
+
|
69
|
+
end # Members
|
70
|
+
end # GithubCLI
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module GithubCLI
|
4
|
+
class Commands::Organizations < Command
|
5
|
+
|
6
|
+
namespace :org
|
7
|
+
|
8
|
+
desc 'list', 'List public and private organizations for the authenticated user'
|
9
|
+
method_option :user, :type => :string, :aliases => ["-u"],
|
10
|
+
:desc => 'List all public organizations for a user',
|
11
|
+
:banner => '<user>'
|
12
|
+
method_option :params, :type => :hash, :default => {},
|
13
|
+
:desc => 'Additional request parameters e.i per_page:100'
|
14
|
+
def list
|
15
|
+
Organization.list options[:user], options[:params], options[:format]
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'get <org>', 'Get properties for a single organization'
|
19
|
+
method_option :params, :type => :hash, :default => {},
|
20
|
+
:desc => 'Additional request parameters e.i per_page:100'
|
21
|
+
def get(org)
|
22
|
+
Organization.get org, options[:params], options[:format]
|
23
|
+
end
|
24
|
+
|
25
|
+
desc 'edit <org>', 'Edit organization'
|
26
|
+
method_option :params, :type => :hash, :default => {},
|
27
|
+
:desc => 'Additonal request parameters e.i per_page:100'
|
28
|
+
long_desc <<-DESC
|
29
|
+
Parameters
|
30
|
+
|
31
|
+
billing_email - Optional string - Billing email address. This address is not publicized.\n
|
32
|
+
company - Optional string\n
|
33
|
+
email - Optional string\n
|
34
|
+
location - Optional string\n
|
35
|
+
name - Optional string\n
|
36
|
+
DESC
|
37
|
+
def edit(org)
|
38
|
+
Oraanization.edit org, options[:params], options[:format]
|
39
|
+
end
|
40
|
+
|
41
|
+
end # Organizations
|
42
|
+
end # GithubCLI
|
@@ -0,0 +1,148 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module GithubCLI
|
4
|
+
class Commands::Teams < Command
|
5
|
+
|
6
|
+
namespace :team
|
7
|
+
|
8
|
+
desc 'list <org>', "List teams"
|
9
|
+
method_option :params, :type => :hash, :default => {},
|
10
|
+
:desc => 'Additional request parameters e.i per_page:100'
|
11
|
+
def list(org)
|
12
|
+
Team.all org, options[:params], options[:format]
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'get <id>', "Get a team"
|
16
|
+
method_option :params, :type => :hash, :default => {},
|
17
|
+
:desc => 'Additional request parameters e.i per_page:100'
|
18
|
+
def get(id)
|
19
|
+
Team.get id, options[:params], options[:format]
|
20
|
+
end
|
21
|
+
|
22
|
+
desc 'create <org>', "Create a team"
|
23
|
+
long_desc <<-DESC
|
24
|
+
In order to create a team, the authenticated user must be an owner of :org.
|
25
|
+
|
26
|
+
Input
|
27
|
+
|
28
|
+
name - Required string\n
|
29
|
+
repo_names - Optional array of strings\n
|
30
|
+
permission - Optional string\n
|
31
|
+
* pull - team members can pull, but not push or administor this repositories. Default\n
|
32
|
+
* push - team members can pull and push, but not administor this repositores.\n
|
33
|
+
* admin - team members can pull, push and administor these repositories.\n
|
34
|
+
DESC
|
35
|
+
method_option :params, :type => :hash, :default => {},
|
36
|
+
:desc => 'Additional request parameters e.i per_page:100'
|
37
|
+
def create(org)
|
38
|
+
Team.create org, options[:params], options[:format]
|
39
|
+
end
|
40
|
+
|
41
|
+
desc 'edit <id>', "Edit team <id>"
|
42
|
+
long_desc <<-DESC
|
43
|
+
In order to edit a team, the authenticated user must be an owner of the org that the team is associated with.
|
44
|
+
|
45
|
+
Input
|
46
|
+
|
47
|
+
name - Required string\n
|
48
|
+
permission - Optional string\n
|
49
|
+
* pull - team members can pull, but not push or administor this repositories. Default\n
|
50
|
+
* push - team members can pull and push, but not administor this repositores.\n
|
51
|
+
* admin - team members can pull, push and administor these repositories.\n
|
52
|
+
DESC
|
53
|
+
method_option :params, :type => :hash, :default => {},
|
54
|
+
:desc => 'Additional request parameters e.i per_page:100'
|
55
|
+
def edit(id)
|
56
|
+
Team.edit id, options[:params], options[:format]
|
57
|
+
end
|
58
|
+
|
59
|
+
desc 'delete <id>', 'Delete team'
|
60
|
+
long_desc <<-DESC
|
61
|
+
In order to delete a team, the authenticated user must be an owner of the org that the team is associated with.
|
62
|
+
DESC
|
63
|
+
method_option :params, :type => :hash, :default => {},
|
64
|
+
:desc => 'Additional request parameters e.i per_page:100'
|
65
|
+
def delete(id)
|
66
|
+
Team.delete id, options[:params], options[:format]
|
67
|
+
end
|
68
|
+
|
69
|
+
desc 'list_member <id>', "List team <id> members"
|
70
|
+
method_option :params, :type => :hash, :default => {},
|
71
|
+
:desc => 'Additional request parameters e.i per_page:100'
|
72
|
+
def list_member(id)
|
73
|
+
Team.all_member id, options[:params], options[:format]
|
74
|
+
end
|
75
|
+
|
76
|
+
desc 'member <id> <user>', 'Check if <user> is a team member'
|
77
|
+
long_desc <<-DESC
|
78
|
+
In order to get if a user is a member of a team, the authenticated user must be a member of the team.
|
79
|
+
DESC
|
80
|
+
method_option :params, :type => :hash, :default => {},
|
81
|
+
:desc => 'Additional request parameters e.i per_page:100'
|
82
|
+
def member(id, user)
|
83
|
+
Team.member id, user, options[:params], options[:format]
|
84
|
+
end
|
85
|
+
|
86
|
+
desc 'add_member <id> <user>', 'Add team member'
|
87
|
+
long_desc <<-DESC
|
88
|
+
In order to add a user to a team, the authenticated user must have ‘admin’ permissions to the team or be an owner of the org that the team is associated with.
|
89
|
+
DESC
|
90
|
+
method_option :params, :type => :hash, :default => {},
|
91
|
+
:desc => 'Additional request parameters e.i per_page:100'
|
92
|
+
def add_member(id, user)
|
93
|
+
Team.add_member id, user, options[:params], options[:format]
|
94
|
+
end
|
95
|
+
|
96
|
+
desc 'remove_member <id> <user>', 'Remove team member'
|
97
|
+
long_desc <<-DESC
|
98
|
+
In order to remove a user from a team, the authenticated user must have
|
99
|
+
‘admin’ permissions to the team or be an owner of the org that the team
|
100
|
+
is associated with. NOTE: This does not delete the user, it just remove
|
101
|
+
them from the team.
|
102
|
+
DESC
|
103
|
+
method_option :params, :type => :hash, :default => {},
|
104
|
+
:desc => 'Additional request parameters e.i per_page:100'
|
105
|
+
def remove_member(id, user)
|
106
|
+
Team.remove_member id, user, options[:params], options[:format]
|
107
|
+
end
|
108
|
+
|
109
|
+
desc 'list_repo <id>', "List team <id> repositories"
|
110
|
+
method_option :params, :type => :hash, :default => {},
|
111
|
+
:desc => 'Additional request parameters e.i per_page:100'
|
112
|
+
def list_repo(id)
|
113
|
+
Team.all_repo id, options[:params], options[:format]
|
114
|
+
end
|
115
|
+
|
116
|
+
desc 'repo <id> <user> <repo>', 'Check if <repo> is managed by <id> team'
|
117
|
+
method_option :params, :type => :hash, :default => {},
|
118
|
+
:desc => 'Additional request parameters e.i per_page:100'
|
119
|
+
def repo(id, user, repo)
|
120
|
+
Team.repo id, user, repo, options[:params], options[:format]
|
121
|
+
end
|
122
|
+
|
123
|
+
desc 'add_repo <id> <user> <repo>', 'Add team <repo>'
|
124
|
+
long_desc <<-DESC
|
125
|
+
In order to add a repo to a team, the authenticated user must be an owner
|
126
|
+
of the org that the team is associated with. Also, the repo must be owned
|
127
|
+
by the organization, or a direct for of a repo owned by the organization.
|
128
|
+
DESC
|
129
|
+
method_option :params, :type => :hash, :default => {},
|
130
|
+
:desc => 'Additional request parameters e.i per_page:100'
|
131
|
+
def add_repo(id, user, repo)
|
132
|
+
Team.add_repo id, user, repo, options[:params], options[:format]
|
133
|
+
end
|
134
|
+
|
135
|
+
desc 'remove_repo <id> <user> <repo>', 'Remove team <repo>'
|
136
|
+
long_desc <<-DESC
|
137
|
+
In order to remove a repo from a team, the authenticated user must be an
|
138
|
+
owner of the org that the team is associated with. NOTE: This does not
|
139
|
+
delete the repo, it just removes it from the team.
|
140
|
+
DESC
|
141
|
+
method_option :params, :type => :hash, :default => {},
|
142
|
+
:desc => 'Additional request parameters e.i per_page:100'
|
143
|
+
def remove_repo(id, user, repo)
|
144
|
+
Team.remove_repo id, user, repo, options[:params], options[:format]
|
145
|
+
end
|
146
|
+
|
147
|
+
end # Teams
|
148
|
+
end # GithubCLI
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module GithubCLI
|
4
|
+
class Commands::Users < Command
|
5
|
+
|
6
|
+
namespace :user
|
7
|
+
|
8
|
+
desc 'get', 'Get the authenticated user'
|
9
|
+
method_option :user, :type => :string, :aliases => ["-u"],
|
10
|
+
:desc => 'Get a single unauthenticated <user>',
|
11
|
+
:banner => '<user>'
|
12
|
+
method_option :params, :type => :hash, :default => {},
|
13
|
+
:desc => 'Additional request parameters e.i per_page:100'
|
14
|
+
def get
|
15
|
+
User.get options[:user], options[:params], options[:format]
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'update', 'Update the authenticated user'
|
19
|
+
method_option :params, :type => :hash, :default => {},
|
20
|
+
:desc => 'Additonal request parameters e.i per_page:100'
|
21
|
+
def update
|
22
|
+
User.update options[:params], options[:format]
|
23
|
+
end
|
24
|
+
|
25
|
+
end # Users
|
26
|
+
end # GithubCLI
|
data/lib/github_cli/commands.rb
CHANGED
@@ -9,18 +9,23 @@ module GithubCLI
|
|
9
9
|
autoload :Downloads, 'github_cli/commands/downloads'
|
10
10
|
autoload :Emails, 'github_cli/commands/emails'
|
11
11
|
autoload :Events, 'github_cli/commands/events'
|
12
|
+
autoload :Followers, 'github_cli/commands/followers'
|
12
13
|
autoload :Forks, 'github_cli/commands/forks'
|
13
14
|
autoload :Gists, 'github_cli/commands/gists'
|
14
15
|
autoload :Hooks, 'github_cli/commands/hooks'
|
15
16
|
autoload :Issues, 'github_cli/commands/issues'
|
16
17
|
autoload :Keys, 'github_cli/commands/keys'
|
17
18
|
autoload :Labels, 'github_cli/commands/labels'
|
19
|
+
autoload :Members, 'github_cli/commands/members'
|
18
20
|
autoload :Milestones, 'github_cli/commands/milestones'
|
21
|
+
autoload :Organizations, 'github_cli/commands/organizations'
|
19
22
|
autoload :PullRequests, 'github_cli/commands/pull_requests'
|
20
23
|
autoload :References, 'github_cli/commands/references'
|
21
24
|
autoload :Repositories, 'github_cli/commands/repositories'
|
22
25
|
autoload :Tags, 'github_cli/commands/tags'
|
26
|
+
autoload :Teams, 'github_cli/commands/teams'
|
23
27
|
autoload :Trees, 'github_cli/commands/trees'
|
28
|
+
autoload :Users, 'github_cli/commands/users'
|
24
29
|
autoload :Watching, 'github_cli/commands/watching'
|
25
30
|
end # Commands
|
26
31
|
end # GithubCLI
|