Class: GithubControl::Actions::AddCollaborators
Instance Method Summary
collapse
#initialize, #options
Instance Method Details
#add_options(parser) ⇒ Object
4
5
6
7
8
9
10
11
12
|
# File 'lib/github-control/actions/add_collaborators.rb', line 4
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
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/github-control/actions/add_collaborators.rb', line 14
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 << user
puts "Done"
end
end
|
#repository ⇒ Object
25
26
27
|
# File 'lib/github-control/actions/add_collaborators.rb', line 25
def repository
@cli.console.current_user.repo_for(options[:repository_name] || raise(ProblemWithOptions, "Please specify a repository"))
end
|
#user ⇒ Object
29
30
31
|
# File 'lib/github-control/actions/add_collaborators.rb', line 29
def user
@cli.console.user_for(options[:user_name] || raise(ProblemWithOptions, "Please specify a user"))
end
|