Skip to content
This repository has been archived by the owner on Mar 3, 2022. It is now read-only.

Commit

Permalink
#239 Adding ability to enable/disable issues
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexChesters committed Oct 16, 2015
1 parent ce7892b commit f007066
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Rakefile
Expand Up @@ -17,6 +17,8 @@ task :build do
lib/ghi/commands/comment.rb
lib/ghi/commands/config.rb
lib/ghi/commands/edit.rb
lib/ghi/commands/disable.rb
lib/ghi/commands/enable.rb
lib/ghi/commands/help.rb
lib/ghi/commands/label.rb
lib/ghi/commands/list.rb
Expand Down
48 changes: 47 additions & 1 deletion ghi
Expand Up @@ -3324,6 +3324,50 @@ EOF
end
end
end
module GHI
module Commands
class Disable < Command

def execute
require_repo
patch_data = {}
# TODO: A way to grap the actual repo name, rather than username/repo
repo_path = repo.partition "/"
patch_data[:name] = repo_path[2]
patch_data[:has_issues] = false
res = throb { api.patch "/repos/#{repo}", patch_data }.body
if !res['has_issues']
puts "Issues are now disabled for this repo"
else
puts "Something went wrong disabling issues for this repo"
end
end

end
end
end
module GHI
module Commands
class Enable < Command

def execute
require_repo
patch_data = {}
# TODO: A way to grap the actual repo name, rather than username/repo
repo_path = repo.partition "/"
patch_data[:name] = repo_path[2]
patch_data[:has_issues] = true
res = throb { api.patch "/repos/#{repo}", patch_data }.body
if res['has_issues']
puts "Issues are now enabled for this repo"
else
puts "Something went wrong enabling issues for this repo"
end
end

end
end
end
module GHI
module Commands
class Help < Command
Expand Down Expand Up @@ -3362,6 +3406,8 @@ The most commonly used ghi commands are:
assign Assign an issue to yourself (or someone else)
milestone Manage project milestones
status Determine whether or not issues are enabled for this repo
enable Enable issues for the current repo
disable Disable issues for the current repo
See 'ghi help <command>' for more information on a specific command.
EOF
Expand Down Expand Up @@ -4019,7 +4065,7 @@ EOF
) do |assignee|
assigns[:assignee] = assignee
end
opts.on '--claim', '--assign', 'assign to yourself' do
opts.on '--claim', 'assign to yourself' do
assigns[:assignee] = Authorization.username
end
opts.on(
Expand Down
2 changes: 2 additions & 0 deletions lib/ghi/commands.rb
Expand Up @@ -8,7 +8,9 @@ module Commands
autoload :Close, 'ghi/commands/close'
autoload :Comment, 'ghi/commands/comment'
autoload :Config, 'ghi/commands/config'
autoload :Disable, 'ghi/commands/disable'
autoload :Edit, 'ghi/commands/edit'
autoload :Enable, 'ghi/commands/enable'
autoload :Help, 'ghi/commands/help'
autoload :Label, 'ghi/commands/label'
autoload :Milestone, 'ghi/commands/milestone'
Expand Down
22 changes: 22 additions & 0 deletions lib/ghi/commands/disable.rb
@@ -0,0 +1,22 @@
module GHI
module Commands
class Disable < Command

def execute
require_repo
patch_data = {}
# TODO: A way to grap the actual repo name, rather than username/repo
repo_path = repo.partition "/"
patch_data[:name] = repo_path[2]
patch_data[:has_issues] = false
res = throb { api.patch "/repos/#{repo}", patch_data }.body
if !res['has_issues']
puts "Issues are now disabled for this repo"
else
puts "Something went wrong disabling issues for this repo"
end
end

end
end
end
22 changes: 22 additions & 0 deletions lib/ghi/commands/enable.rb
@@ -0,0 +1,22 @@
module GHI
module Commands
class Enable < Command

def execute
require_repo
patch_data = {}
# TODO: A way to grap the actual repo name, rather than username/repo
repo_path = repo.partition "/"
patch_data[:name] = repo_path[2]
patch_data[:has_issues] = true
res = throb { api.patch "/repos/#{repo}", patch_data }.body
if res['has_issues']
puts "Issues are now enabled for this repo"
else
puts "Something went wrong enabling issues for this repo"
end
end

end
end
end
2 changes: 2 additions & 0 deletions lib/ghi/commands/help.rb
Expand Up @@ -36,6 +36,8 @@ def execute message = nil
assign Assign an issue to yourself (or someone else)
milestone Manage project milestones
status Determine whether or not issues are enabled for this repo
enable Enable issues for the current repo
disable Disable issues for the current repo
See 'ghi help <command>' for more information on a specific command.
EOF
Expand Down

0 comments on commit f007066

Please sign in to comment.