Class: GithubControl::Actions::AddCollaborators
Instance Method Summary
collapse
#initialize, #options, register, set
Instance Method Details
#add_options(parser) ⇒ Object
6
7
8
9
10
11
12
13
14
|
# File 'lib/github-control/actions/add_collaborators.rb', line 6
def add_options(parser)
parser.on("-R name", "--repository name", "The repository on Github") do |repository_name|
options[:repository_name] = repository_name
end
parser.on("-U name", "--user name", "The user on Github") do |user_name|
options[:user_name] = user_name
end
end
|
#call ⇒ Object
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/github-control/actions/add_collaborators.rb', line 16
def call
puts "Adding #{user.name} to the collaborators of #{repository.full_name}"
puts "-" * 40
if repository.collaborators.include?(user)
puts "#{user.name} is already a collaborator"
else
repository.collaborators.create(user.name)
puts "Done"
end
end
|
#repository ⇒ Object
27
28
29
|
# File 'lib/github-control/actions/add_collaborators.rb', line 27
def repository
@cli.console.current_user.repositories.get(options[:repository_name] || raise(ProblemWithOptions, "Please specify a repository"))
end
|
#user ⇒ Object
31
32
33
|
# File 'lib/github-control/actions/add_collaborators.rb', line 31
def user
@cli.console.user_for(options[:user_name] || raise(ProblemWithOptions, "Please specify a user"))
end
|