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.
Files changed (127) hide show
  1. data/.travis.yml +1 -0
  2. data/CHANGELOG.md +12 -1
  3. data/Gemfile.lock +12 -10
  4. data/README.md +18 -0
  5. data/features/authorization.feature +53 -0
  6. data/features/blob.feature +1 -1
  7. data/features/download.feature +13 -11
  8. data/features/gist.feature +9 -1
  9. data/features/label.feature +11 -12
  10. data/features/member.feature +5 -4
  11. data/features/merging.feature +5 -4
  12. data/features/organization.feature +5 -4
  13. data/features/repository.feature +9 -1
  14. data/features/search.feature +5 -4
  15. data/github_cli.gemspec +1 -1
  16. data/lib/github_cli/api.rb +56 -49
  17. data/lib/github_cli/apis/assignee.rb +6 -6
  18. data/lib/github_cli/apis/authorization.rb +5 -5
  19. data/lib/github_cli/apis/blob.rb +6 -6
  20. data/lib/github_cli/apis/collaborator.rb +12 -12
  21. data/lib/github_cli/apis/commit.rb +6 -6
  22. data/lib/github_cli/apis/content.rb +9 -9
  23. data/lib/github_cli/apis/download.rb +15 -15
  24. data/lib/github_cli/apis/email.rb +9 -9
  25. data/lib/github_cli/apis/event.rb +24 -24
  26. data/lib/github_cli/apis/follower.rb +16 -15
  27. data/lib/github_cli/apis/fork.rb +6 -6
  28. data/lib/github_cli/apis/gist.rb +31 -30
  29. data/lib/github_cli/apis/hook.rb +6 -6
  30. data/lib/github_cli/apis/issue.rb +12 -12
  31. data/lib/github_cli/apis/key.rb +15 -15
  32. data/lib/github_cli/apis/label.rb +24 -26
  33. data/lib/github_cli/apis/member.rb +15 -27
  34. data/lib/github_cli/apis/merging.rb +3 -3
  35. data/lib/github_cli/apis/milestone.rb +15 -15
  36. data/lib/github_cli/apis/notification.rb +18 -18
  37. data/lib/github_cli/apis/organization.rb +9 -9
  38. data/lib/github_cli/apis/pull_request.rb +24 -24
  39. data/lib/github_cli/apis/reference.rb +15 -15
  40. data/lib/github_cli/apis/repository.rb +13 -12
  41. data/lib/github_cli/apis/search.rb +12 -12
  42. data/lib/github_cli/apis/starring.rb +15 -15
  43. data/lib/github_cli/apis/status.rb +6 -6
  44. data/lib/github_cli/apis/tag.rb +6 -6
  45. data/lib/github_cli/apis/team.rb +39 -39
  46. data/lib/github_cli/apis/tree.rb +6 -6
  47. data/lib/github_cli/apis/user.rb +9 -9
  48. data/lib/github_cli/apis/watching.rb +15 -15
  49. data/lib/github_cli/cli.rb +24 -16
  50. data/lib/github_cli/commands/assignees.rb +8 -2
  51. data/lib/github_cli/commands/authorizations.rb +10 -13
  52. data/lib/github_cli/commands/blobs.rb +9 -3
  53. data/lib/github_cli/commands/collaborators.rb +16 -4
  54. data/lib/github_cli/commands/commits.rb +11 -6
  55. data/lib/github_cli/commands/contents.rb +9 -6
  56. data/lib/github_cli/commands/downloads.rb +30 -6
  57. data/lib/github_cli/commands/emails.rb +12 -3
  58. data/lib/github_cli/commands/events.rb +30 -8
  59. data/lib/github_cli/commands/followers.rb +20 -5
  60. data/lib/github_cli/commands/forks.rb +6 -4
  61. data/lib/github_cli/commands/gists.rb +39 -12
  62. data/lib/github_cli/commands/hooks.rb +1 -1
  63. data/lib/github_cli/commands/issues.rb +15 -4
  64. data/lib/github_cli/commands/keys.rb +20 -5
  65. data/lib/github_cli/commands/labels.rb +53 -14
  66. data/lib/github_cli/commands/members.rb +28 -9
  67. data/lib/github_cli/commands/merging.rb +3 -2
  68. data/lib/github_cli/commands/milestones.rb +27 -15
  69. data/lib/github_cli/commands/notifications.rb +19 -11
  70. data/lib/github_cli/commands/organizations.rb +24 -5
  71. data/lib/github_cli/commands/pull_requests.rb +30 -8
  72. data/lib/github_cli/commands/references.rb +17 -5
  73. data/lib/github_cli/commands/repositories.rb +6 -4
  74. data/lib/github_cli/commands/search.rb +24 -6
  75. data/lib/github_cli/commands/starring.rb +19 -5
  76. data/lib/github_cli/commands/statuses.rb +7 -3
  77. data/lib/github_cli/commands/tags.rb +7 -3
  78. data/lib/github_cli/commands/teams.rb +52 -17
  79. data/lib/github_cli/commands/trees.rb +6 -2
  80. data/lib/github_cli/commands/users.rb +9 -3
  81. data/lib/github_cli/commands/watching.rb +19 -5
  82. data/lib/github_cli/vendor/thor/actions/directory.rb +2 -0
  83. data/lib/github_cli/vendor/thor/actions/empty_directory.rb +3 -19
  84. data/lib/github_cli/vendor/thor/actions/file_manipulation.rb +4 -1
  85. data/lib/github_cli/vendor/thor/actions.rb +1 -1
  86. data/lib/github_cli/vendor/thor/base.rb +20 -18
  87. data/lib/github_cli/vendor/thor/command.rb +1 -1
  88. data/lib/github_cli/vendor/thor/error.rb +0 -4
  89. data/lib/github_cli/vendor/thor/group.rb +4 -9
  90. data/lib/github_cli/vendor/thor/runner.rb +1 -1
  91. data/lib/github_cli/vendor/thor/shell/basic.rb +25 -7
  92. data/lib/github_cli/vendor/thor/version.rb +1 -1
  93. data/lib/github_cli/vendor/thor.rb +17 -2
  94. data/lib/github_cli/version.rb +1 -1
  95. data/spec/github_cli/api/configure_spec.rb +50 -0
  96. data/spec/github_cli/api/github_api_spec.rb +19 -0
  97. data/spec/github_cli/commands/assignees_spec.rb +1 -1
  98. data/spec/github_cli/commands/blobs_spec.rb +1 -1
  99. data/spec/github_cli/commands/collaborators_spec.rb +1 -1
  100. data/spec/github_cli/commands/commits_spec.rb +1 -1
  101. data/spec/github_cli/commands/contents_spec.rb +1 -1
  102. data/spec/github_cli/commands/downloads_spec.rb +35 -0
  103. data/spec/github_cli/commands/emails_spec.rb +1 -1
  104. data/spec/github_cli/commands/events_spec.rb +1 -1
  105. data/spec/github_cli/commands/followers_spec.rb +1 -1
  106. data/spec/github_cli/commands/forks_spec.rb +1 -1
  107. data/spec/github_cli/commands/gists_spec.rb +6 -1
  108. data/spec/github_cli/commands/issues_spec.rb +1 -1
  109. data/spec/github_cli/commands/keys_spec.rb +1 -1
  110. data/spec/github_cli/commands/labels_spec.rb +13 -3
  111. data/spec/github_cli/commands/members_spec.rb +46 -0
  112. data/spec/github_cli/commands/merging_spec.rb +1 -1
  113. data/spec/github_cli/commands/milestones_spec.rb +1 -1
  114. data/spec/github_cli/commands/notifications_spec.rb +1 -1
  115. data/spec/github_cli/commands/organizations_spec.rb +30 -0
  116. data/spec/github_cli/commands/pull_requests_spec.rb +1 -1
  117. data/spec/github_cli/commands/references_spec.rb +1 -1
  118. data/spec/github_cli/commands/repositories_spec.rb +5 -0
  119. data/spec/github_cli/commands/starring_spec.rb +1 -1
  120. data/spec/github_cli/commands/statuses_spec.rb +1 -1
  121. data/spec/github_cli/commands/tags_spec.rb +1 -1
  122. data/spec/github_cli/commands/teams_spec.rb +1 -1
  123. data/spec/github_cli/commands/trees_spec.rb +1 -1
  124. data/spec/github_cli/commands/users_spec.rb +1 -1
  125. data/spec/github_cli/commands/watching_spec.rb +1 -1
  126. metadata +27 -17
  127. data/spec/github_cli/api_spec.rb +0 -19
@@ -20,16 +20,21 @@ module GithubCLI
20
20
  direction - asc, desc, default: desc\n
21
21
  DESC
22
22
  def list(user, repo)
23
+ global_options = options.dup
23
24
  params = options[:params].dup
24
- params['state'] = options[:state] || 'open'
25
- params['sort'] = options[:sort] || 'due_date'
25
+ params['state'] = options[:state] || 'open'
26
+ params['sort'] = options[:sort] || 'due_date'
26
27
  params['direction'] = options[:direction] || 'desc'
27
- Milestone.all user, repo, params, options[:format]
28
+ Util.hash_without!(global_options, params.keys + ['params'])
29
+ Milestone.all user, repo, params, global_options
28
30
  end
29
31
 
30
32
  desc 'get <user> <repo> <number>', 'Get a single milestone'
31
33
  def get(user, repo, number)
32
- Milestone.get user, repo, number, options[:params], options[:format]
34
+ global_options = options.dup
35
+ params = options[:params].dup
36
+ Util.hash_without!(global_options, params.keys + ['params'])
37
+ Milestone.get user, repo, number, params, global_options
33
38
  end
34
39
 
35
40
  desc 'create <user> <repo>', 'Create a milestone'
@@ -51,12 +56,14 @@ module GithubCLI
51
56
  ghc milestone create wycats thor --title=new
52
57
  DESC
53
58
  def create(user, repo)
59
+ global_options = options.dup
54
60
  params = options[:params].dup
55
- params['title'] = options[:title]
56
- params['state'] = options[:state] if options[:state]
57
- params['description'] = options[:desc] if options[:desc]
58
- params['due_on'] = options[:due_on] if options[:due_on]
59
- Milestone.create user, repo, params, options[:format]
61
+ params['title'] = options[:title]
62
+ params['state'] = options[:state] if options[:state]
63
+ params['description'] = options[:desc] if options[:desc]
64
+ params['due_on'] = options[:due_on] if options[:due_on]
65
+ Util.hash_without!(global_options, params.keys + ['params'])
66
+ Milestone.create user, repo, params, global_options
60
67
  end
61
68
 
62
69
  desc 'update <user> <repo> <number>', 'Update a milestone'
@@ -78,17 +85,22 @@ module GithubCLI
78
85
  ghc milestone update wycats thor 1 --title=new
79
86
  DESC
80
87
  def update(user, repo, number)
88
+ global_options = options.dup
81
89
  params = options[:params].dup
82
- params['title'] = options[:title] if options[:title]
83
- params['state'] = options[:state] if options[:state]
84
- params['description'] = options[:desc] if options[:desc]
85
- params['due_on'] = options[:due_on] if options[:due_on]
86
- Milestone.update user, repo, number, params, options[:format]
90
+ params['title'] = options[:title] if options[:title]
91
+ params['state'] = options[:state] if options[:state]
92
+ params['description'] = options[:desc] if options[:desc]
93
+ params['due_on'] = options[:due_on] if options[:due_on]
94
+ Util.hash_without!(global_options, params.keys + ['params'])
95
+ Milestone.update user, repo, number, params, global_options
87
96
  end
88
97
 
89
98
  desc 'delete <user> <repo> <number>', 'Delete a milestone'
90
99
  def delete(user, repo, number)
91
- Milestone.delete user, repo, number, options[:params], options[:format]
100
+ global_options = options.dup
101
+ params = options[:params].dup
102
+ Util.hash_without!(global_options, params.keys + ['params'])
103
+ Milestone.delete user, repo, number, params, global_options
92
104
  end
93
105
 
94
106
  end # Milestones
@@ -22,16 +22,20 @@ module GithubCLI
22
22
  since - Optional time - filters out any notifications updated before the given time.\n
23
23
  DESC
24
24
  def list
25
+ global_options = options.dup
25
26
  params = options[:params].dup
26
27
  params['user'] = options[:user] if options[:user]
27
28
  params['repo'] = options[:repo] if options[:repo]
28
-
29
- Notification.all params, options[:format]
29
+ Util.hash_without!(global_options, params.keys + ['params'])
30
+ Notification.all params, global_options
30
31
  end
31
32
 
32
33
  desc 'get <id>', 'View a single thread'
33
34
  def get(id)
34
- Notification.get id, options[:params], options[:format]
35
+ global_options = options.dup
36
+ params = options[:params].dup
37
+ Util.hash_without!(global_options, params.keys + ['params'])
38
+ Notification.get id, params, global_options
35
39
  end
36
40
 
37
41
  option :user, :type => :string, :aliases => ["-u"]
@@ -40,20 +44,22 @@ module GithubCLI
40
44
  option :id, :type => :numeric, :desc => "thread id to be marked"
41
45
  desc 'mark', 'Mark as read'
42
46
  def mark
47
+ global_options = options.dup
43
48
  params = options[:params].dup
44
49
  params['user'] = options[:user] if options[:user]
45
50
  params['repo'] = options[:repo] if options[:repo]
46
51
  params['read'] = options[:read] if options[:read]
47
52
  params['thread_id'] = options[:id] if options[:id]
48
-
49
- Notification.mark params, options[:format]
53
+ Util.hash_without!(global_options, params.keys + ['params', 'id'])
54
+ Notification.mark params, global_options
50
55
  end
51
56
 
52
57
  desc 'check', 'Check to see if the current user is subscribed to a thread'
53
58
  def check(id)
59
+ global_options = options.dup
54
60
  params = options[:params].dup
55
-
56
- Notification.subscribed? id, params, options[:format]
61
+ Util.hash_without!(global_options, params.keys + ['params'])
62
+ Notification.subscribed? id, params, global_options
57
63
  end
58
64
 
59
65
  option :subscribed, :type => :boolean,
@@ -67,18 +73,20 @@ module GithubCLI
67
73
  a thread will mute all future notifications (until you comment or get @mentioned).
68
74
  DESC
69
75
  def create(id)
76
+ global_options = options.dup
70
77
  params = options[:params].dup
71
78
  params['subscribed'] = options[:subscribed] if options[:subscrirbed]
72
79
  params['ignored'] = options[:ignored] if options[:ignored]
73
-
74
- Notification.create id, params, options[:format]
80
+ Util.hash_without!(global_options, params.keys + ['params'])
81
+ Notification.create id, params, global_options
75
82
  end
76
83
 
77
84
  desc 'delete', 'Delete a thread subscription'
78
85
  def delete(id)
86
+ global_options = options.dup
79
87
  params = options[:params].dup
80
-
81
- Notification.delete id, params, options[:format]
88
+ Util.hash_without!(global_options, params.keys + ['params'])
89
+ Notification.delete id, params, global_options
82
90
  end
83
91
 
84
92
  end # Notifications
@@ -10,15 +10,26 @@ module GithubCLI
10
10
  :desc => 'List all public organizations for a user',
11
11
  :banner => '<user>'
12
12
  def list
13
- options[:params]['user'] = options[:user] if options[:user]
14
- Organization.list options[:params], options[:format]
13
+ global_options = options.dup
14
+ params = options[:params].dup
15
+ params['user'] = options[:user] if options[:user]
16
+ Util.hash_without!(global_options, params.keys + ['params'])
17
+ Organization.list params, global_options
15
18
  end
16
19
 
17
20
  desc 'get <org>', 'Get properties for a single organization'
18
21
  def get(org)
19
- Organization.get org, options[:params], options[:format]
22
+ global_options = options.dup
23
+ params = options[:params].dup
24
+ Util.hash_without!(global_options, params.keys + ['params'])
25
+ Organization.get org, params, global_options
20
26
  end
21
27
 
28
+ option :billing_email, :type => :string
29
+ option :company, :type => :string
30
+ option :email, :type => :string
31
+ option :location, :type => :string
32
+ option :name, :type => :string
22
33
  desc 'edit <org>', 'Edit organization'
23
34
  long_desc <<-DESC
24
35
  Parameters
@@ -31,10 +42,18 @@ module GithubCLI
31
42
 
32
43
  Example
33
44
 
34
- ghc org edit rails --params=name:github company:GitHub email:support@github.com
45
+ gcli org edit rails --name=github --company=GitHub --email=support@github.com
35
46
  DESC
36
47
  def edit(org)
37
- Organization.edit org, options[:params], options[:format]
48
+ global_options = options.dup
49
+ params = options[:params].dup
50
+ params['billing_email'] = options[:billing_email] if options[:billing_email]
51
+ params['company'] = options[:company] if options[:company]
52
+ params['email'] = options[:email] if options[:email]
53
+ params['location'] = options[:location] if options[:location]
54
+ params['name'] = options[:name] if options[:name]
55
+ Util.hash_without!(global_options, params.keys + ['params'])
56
+ Organization.edit org, params, global_options
38
57
  end
39
58
 
40
59
  end # Organizations
@@ -7,12 +7,18 @@ module GithubCLI
7
7
 
8
8
  desc 'list <user> <repo>', 'List all Pull Requests'
9
9
  def list(user, repo)
10
- PullRequest.list user, repo, options[:params], options[:format]
10
+ global_options = options.dup
11
+ params = options[:params].dup
12
+ Util.hash_without!(global_options, params.keys + ['params'])
13
+ PullRequest.list user, repo, params, global_options
11
14
  end
12
15
 
13
16
  desc 'get <user> <repo> <number>', 'Get a Pull Request'
14
17
  def get(user, repo, number)
15
- PullRequest.get user, repo, number, options[:params], options[:format]
18
+ global_options = options.dup
19
+ params = options[:params].dup
20
+ Util.hash_without!(global_options, params.keys + ['params'])
21
+ PullRequest.get user, repo, number, params, global_options
16
22
  end
17
23
 
18
24
  desc 'create <user> <repo>', 'Create a new Pull Request'
@@ -25,13 +31,15 @@ module GithubCLI
25
31
  option :issue, :type => :string,
26
32
  :desc => "Issue number in this repository to turn into a Pull Request"
27
33
  def create(user, repo)
34
+ global_options = options.dup
28
35
  params = options[:params].dup
29
36
  params['title'] = options[:title] if options[:title]
30
37
  params['body'] = options[:body] if options[:body]
31
38
  params['base'] = options[:base] if options[:base]
32
39
  params['head'] = options[:head] if options[:head]
33
40
  params['issue'] = options[:issue] if options[:issue]
34
- PullRequest.create user, repo, params, options[:format]
41
+ Util.hash_without!(global_options, params.keys + ['params'])
42
+ PullRequest.create user, repo, params, global_options
35
43
  end
36
44
 
37
45
  desc 'update <user> <repo> <number>', 'Update a Pull Request'
@@ -40,31 +48,45 @@ module GithubCLI
40
48
  option :state, :type => :string,
41
49
  :desc => "State of this Pull Request. Valid values are open and closed"
42
50
  def update(user, repo, number)
51
+ global_options = options.dup
43
52
  params = options[:params].dup
44
53
  params['title'] = options[:title] if options[:title]
45
54
  params['body'] = options[:body] if options[:body]
46
55
  params['state'] = options[:state] if options[:state]
47
- PullRequest.update user, repo, number, params, options[:format]
56
+ Util.hash_without!(global_options, params.keys + ['params'])
57
+ PullRequest.update user, repo, number, params, global_options
48
58
  end
49
59
 
50
60
  desc 'commits <user> <repo> <number>', 'List commits on a Pull Request'
51
61
  def commits(user, repo, number)
52
- PullRequest.commits user, repo, number, options[:params], options[:format]
62
+ global_options = options.dup
63
+ params = options[:params].dup
64
+ Util.hash_without!(global_options, params.keys + ['params'])
65
+ PullRequest.commits user, repo, number, params, global_options
53
66
  end
54
67
 
55
68
  desc 'files <user> <repo> <number>', 'List Pull Requests Files'
56
69
  def files(user, repo, number)
57
- PullRequest.files user, repo, number, options[:params], options[:format]
70
+ global_options = options.dup
71
+ params = options[:params].dup
72
+ Util.hash_without!(global_options, params.keys + ['params'])
73
+ PullRequest.files user, repo, number, params, global_options
58
74
  end
59
75
 
60
76
  desc 'merged <user> <repo> <number>', 'Get if a pull request has been merged'
61
77
  def merged(user, repo, number)
62
- PullRequest.merged user, repo, number, options[:params], options[:format]
78
+ global_options = options.dup
79
+ params = options[:params].dup
80
+ Util.hash_without!(global_options, params.keys + ['params'])
81
+ PullRequest.merged user, repo, number, params, global_options
63
82
  end
64
83
 
65
84
  desc 'merge <user> <repo> <number>', 'Merge a pull request'
66
85
  def merge(user, repo, number)
67
- PullRequest.merge user, repo, number, options[:params], options[:format]
86
+ global_options = options.dup
87
+ params = options[:params].dup
88
+ Util.hash_without!(global_options, params.keys + ['params'])
89
+ PullRequest.merge user, repo, number, params, global_options
68
90
  end
69
91
 
70
92
  end # PullRequests
@@ -8,16 +8,21 @@ module GithubCLI
8
8
  desc 'list <user> <repo>', 'List all References'
9
9
  option :ref, :type => :string, :banner => 'branch reference'
10
10
  def list(user, repo)
11
+ global_options = options.dup
11
12
  params = options[:params].dup
12
13
  if options[:ref]
13
14
  params['ref'] = options[:ref]
14
15
  end
15
- Reference.list user, repo, params, options[:format]
16
+ Util.hash_without!(global_options, params.keys + ['params'])
17
+ Reference.list user, repo, params, global_options
16
18
  end
17
19
 
18
20
  desc 'get <user> <repo> <ref>', 'Get a Reference'
19
21
  def get(user, repo, ref)
20
- Reference.get user, repo, ref, options[:params], options[:format]
22
+ global_options = options.dup
23
+ params = options[:params].dup
24
+ Util.hash_without!(global_options, params.keys + ['params'])
25
+ Reference.get user, repo, ref, params, global_options
21
26
  end
22
27
 
23
28
  desc 'create <user> <repo>', 'Create a new Reference'
@@ -32,10 +37,12 @@ module GithubCLI
32
37
  sha - String of the SHA1 value to set this reference to.
33
38
  DESC
34
39
  def create(user, repo)
40
+ global_options = options.dup
35
41
  params = options[:params].dup
36
42
  params['ref'] = options[:ref] if options[:ref]
37
43
  params['sha'] = options[:sha] if options[:sha]
38
- Reference.create user, repo, params, options[:format]
44
+ Util.hash_without!(global_options, params.keys + ['params'])
45
+ Reference.create user, repo, params, global_options
39
46
  end
40
47
 
41
48
  desc 'update <user> <repo> <ref>', 'Update a Reference'
@@ -50,15 +57,20 @@ module GithubCLI
50
57
  force - Boolean indicating whether to force the update or to make sure the update is a fast-forward update. The default is <tt>false</tt>, so leaving this out or setting it to false will make sure you’re not overwriting work.
51
58
  DESC
52
59
  def update(user, repo, ref)
60
+ global_options = options.dup
53
61
  params = options[:params].dup
54
62
  params['sha'] = options[:sha] if options[:sha]
55
63
  params['force'] = options[:force] || false
56
- Reference.update user, repo, ref, params, options[:format]
64
+ Util.hash_without!(global_options, params.keys + ['params'])
65
+ Reference.update user, repo, ref, params, global_options
57
66
  end
58
67
 
59
68
  desc 'delete <user> <repo> <ref>', 'Delete a Reference'
60
69
  def delete(user, repo, ref)
61
- Reference.delete user, repo, ref, options[:params], options[:format]
70
+ global_options = options.dup
71
+ params = options[:params].dup
72
+ Util.hash_without!(global_options, params.keys + ['params'])
73
+ Reference.delete user, repo, ref, params, global_options
62
74
  end
63
75
 
64
76
  end # References
@@ -9,6 +9,8 @@ module GithubCLI
9
9
  :desc => 'List repositories for <organization>'
10
10
  option :user, :type => :string, :aliases => ["-u"], :banner => '<user>',
11
11
  :desc => 'List repositories for <user>'
12
+ option :every, :type => :boolean, :default => false,
13
+ :desc => "This provides a dump of every repository, in the order that they were created."
12
14
  option :since, :type => :string, :banner => '<id>',
13
15
  :desc => "the integer ID of the last Repository that you've seen"
14
16
  option :type, :type => :string,
@@ -21,11 +23,11 @@ module GithubCLI
21
23
  def list
22
24
  global_options = options.dup
23
25
  params = options[:params].dup
24
- params['org'] = options[:org] if options[:org]
25
- params['user'] = options[:user] if options[:user]
26
+ params['org'] = options[:org] if options[:org]
27
+ params['user'] = options[:user] if options[:user]
26
28
  params['since'] = options[:since] if options[:since]
27
- params['type'] = options[:type] if options[:type]
28
- params['sort'] = options[:sort] if options[:sort]
29
+ params['type'] = options[:type] if options[:type]
30
+ params['sort'] = options[:sort] if options[:sort]
29
31
  params['direction'] = options[:direction] if options[:direction]
30
32
  Util.hash_without!(global_options, params.keys + ['params'])
31
33
  Repository.all params, global_options
@@ -5,6 +5,7 @@ module GithubCLI
5
5
 
6
6
  namespace :search
7
7
 
8
+ option :state, :type => :string, :aliases => ["-s"], :desc => 'Repository name'
8
9
  desc 'issue <owner> <repo> <keyword>', 'Search issues'
9
10
  long_desc <<-DESC
10
11
  Search issues
@@ -14,25 +15,42 @@ module GithubCLI
14
15
  state - open or closed. \n
15
16
  keyword - search term
16
17
  DESC
17
- method_option :state, :type => :string, :aliases => ["-s"],
18
- :desc => 'Repository name'
19
18
  def issue(owner, repo, keyword)
20
- Search.issue owner, repo, keyword, options[:params].update(:state => options[:state]), options[:format]
19
+ global_options = options.dup
20
+ params = options[:params].dup
21
+ params['owner'] = owner
22
+ params['repo'] = repo
23
+ params['keyword'] = keyword
24
+ params['state'] = options[:state] if options[:state]
25
+ Util.hash_without!(global_options, params.keys + ['params'])
26
+ Search.issue params, global_options
21
27
  end
22
28
 
23
29
  desc 'repo <keyword>', 'Repository search'
24
30
  def repo(keyword)
25
- Search.repo options[:params].update(:keyword => keyword), options[:format]
31
+ global_options = options.dup
32
+ params = options[:params].dup
33
+ params['keyword'] = keyword
34
+ Util.hash_without!(global_options, params.keys + ['params'])
35
+ Search.repo params, global_options
26
36
  end
27
37
 
28
38
  desc 'user <keyword>', 'User search'
29
39
  def user(keyword)
30
- Search.user options[:params].update(:keyword => keyword), options[:format]
40
+ global_options = options.dup
41
+ params = options[:params].dup
42
+ params['keyword'] = keyword
43
+ Util.hash_without!(global_options, params.keys + ['params'])
44
+ Search.user params, global_options
31
45
  end
32
46
 
33
47
  desc 'email <email>', 'Email search'
34
48
  def email(email)
35
- Search.email options[:params].update(:email => email), options[:format]
49
+ global_options = options.dup
50
+ params = options[:params].dup
51
+ params['email'] = email
52
+ Util.hash_without!(global_options, params.keys + ['params'])
53
+ Search.email params, global_options
36
54
  end
37
55
 
38
56
  end # Search
@@ -7,7 +7,10 @@ module GithubCLI
7
7
 
8
8
  desc 'list <user> <repo>', 'Lists stargazers'
9
9
  def list(user, repo)
10
- Starring.list user, repo, options[:params], options[:format]
10
+ global_options = options.dup
11
+ params = options[:params].dup
12
+ Util.hash_without!(global_options, params.keys + ['params'])
13
+ Starring.list user, repo, params, global_options
11
14
  end
12
15
 
13
16
  desc 'starred', 'Lists repos being starred by a user'
@@ -15,25 +18,36 @@ module GithubCLI
15
18
  :desc => 'Starred repositories for <user>'
16
19
  def starred
17
20
  params = options[:params].dup
21
+ global_options = options.dup
18
22
  if options[:user]
19
23
  params['user'] = options[:user]
20
24
  end
21
- Starring.starred params, options[:format]
25
+ Util.hash_without!(global_options, params.keys + ['params', 'user'])
26
+ Starring.starred params, global_options
22
27
  end
23
28
 
24
29
  desc 'starring <user> <repo>', 'Check if you are starring a repository'
25
30
  def starring(user, repo)
26
- Starring.starring? user, repo, options[:params], options[:format]
31
+ global_options = options.dup
32
+ params = options[:params].dup
33
+ Util.hash_without!(global_options, params.keys + ['params'])
34
+ Starring.starring? user, repo, params, global_options
27
35
  end
28
36
 
29
37
  desc 'star <user> <repo>', 'Star a repository'
30
38
  def star(user, repo)
31
- Starring.star user, repo, options[:params], options[:format]
39
+ global_options = options.dup
40
+ params = options[:params].dup
41
+ Util.hash_without!(global_options, params.keys + ['params'])
42
+ Starring.star user, repo, params, global_options
32
43
  end
33
44
 
34
45
  desc 'unstar <user> <repo>', 'Unstar a repository'
35
46
  def unstar(user, repo)
36
- Starring.unstar user, repo, options[:params], options[:format]
47
+ global_options = options.dup
48
+ params = options[:params].dup
49
+ Util.hash_without!(global_options, params.keys + ['params'])
50
+ Starring.unstar user, repo, params, global_options
37
51
  end
38
52
 
39
53
  end # Starring
@@ -7,7 +7,10 @@ module GithubCLI
7
7
 
8
8
  desc 'list <user> <repo> <sha>', 'Lists statuses for a <sha>'
9
9
  def list(user, repo, sha)
10
- Status.all user, repo, sha, options[:params], options[:format]
10
+ global_options = options.dup
11
+ params = options[:params].dup
12
+ Util.hash_without!(global_options, params.keys + ['params'])
13
+ Status.all user, repo, sha, params, global_options
11
14
  end
12
15
 
13
16
  option :state, :type => :string, :required => true,
@@ -25,12 +28,13 @@ module GithubCLI
25
28
  description - Optional string - Short description of the status\n
26
29
  DESC
27
30
  def create(user, repo, sha)
31
+ global_options = options.dup
28
32
  params = options[:params].dup
29
33
  params['state'] = options[:state] if options[:state]
30
34
  params['target_url'] = options[:target] if options[:target]
31
35
  params['description'] = options[:desc] if options[:desc]
32
-
33
- Status.create user, repo, sha, params, options[:format]
36
+ Util.hash_without!(global_options, params.keys + ['params', 'target'])
37
+ Status.create user, repo, sha, params, global_options
34
38
  end
35
39
 
36
40
  end # Statuses
@@ -9,7 +9,10 @@ module GithubCLI
9
9
  method_option :recursive, :type => :boolean, :aliases => ["-r"],
10
10
  :desc => 'get a tree recursively'
11
11
  def get(user, repo, sha)
12
- Tag.get user, repo, sha, options[:params], options[:format]
12
+ global_options = options.dup
13
+ params = options[:params].dup
14
+ Util.hash_without!(global_options, params.keys + ['params'])
15
+ Tag.get user, repo, sha, params, global_options
13
16
  end
14
17
 
15
18
  desc 'create <user> <repo>', 'Create a Tag Object'
@@ -39,14 +42,15 @@ module GithubCLI
39
42
  tagger.date - Timestamp of when this object was tagged \n
40
43
  DESC
41
44
  def create(user, repo)
45
+ global_options = options.dup
42
46
  params = options[:params].dup
43
47
  params['tag'] = options[:tag] if options[:tag]
44
48
  params['message'] = options[:message] if options[:message]
45
49
  params['object'] = options[:object] if options[:object]
46
50
  params['type'] = optiosn[:type] if options[:type]
47
51
  params['tagger'] = options[:tagger] if options[:tagger]
48
-
49
- Tag.create user, repo, params, options[:format]
52
+ Util.hash_without!(global_options, params.keys + ['params'])
53
+ Tag.create user, repo, params, global_options
50
54
  end
51
55
 
52
56
  end # Tag