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
@@ -7,7 +7,10 @@ module GithubCLI
7
7
 
8
8
  desc 'list', 'Lists email addresses for the authenticated user'
9
9
  def list
10
- Email.all options[:params], options[:format]
10
+ global_options = options.dup
11
+ params = options[:params].dup
12
+ Util.hash_without!(global_options, params.keys + ['params'])
13
+ Email.all params, global_options
11
14
  end
12
15
 
13
16
  desc 'add <email>[<email>...]', 'Add email address(es) for the authenticated user'
@@ -15,7 +18,10 @@ module GithubCLI
15
18
  You can include a single email address or an array of addresses
16
19
  DESC
17
20
  def add(*emails)
18
- Email.add emails, options[:params], options[:format]
21
+ global_options = options.dup
22
+ params = options[:params].dup
23
+ Util.hash_without!(global_options, params.keys + ['params'])
24
+ Email.add emails, params, global_options
19
25
  end
20
26
 
21
27
  desc 'delete <email>[<email>...]', 'Delete email address(es) for the authenticated user'
@@ -23,7 +29,10 @@ module GithubCLI
23
29
  You can include a single email address or an array of addresses
24
30
  DESC
25
31
  def delete(*emails)
26
- Email.delete emails, options[:params], options[:format]
32
+ global_options = options.dup
33
+ params = options[:params].dup
34
+ Util.hash_without!(global_options, params.keys + ['params'])
35
+ Email.delete emails, params, global_options
27
36
  end
28
37
 
29
38
  end # Emails
@@ -7,27 +7,42 @@ module GithubCLI
7
7
 
8
8
  desc 'public', 'Lists all public events'
9
9
  def public
10
- Event.public options[:params], options[:format]
10
+ global_options = options.dup
11
+ params = options[:params].dup
12
+ Util.hash_without!(global_options, params.keys + ['params'])
13
+ Event.public params, global_options
11
14
  end
12
15
 
13
16
  desc 'repo <user> <repo>', 'Lists all repository events for a given user'
14
17
  def repo(user, repo)
15
- Event.repository user, repo, options[:params], options[:format]
18
+ global_options = options.dup
19
+ params = options[:params].dup
20
+ Util.hash_without!(global_options, params.keys + ['params'])
21
+ Event.repository user, repo, params, global_options
16
22
  end
17
23
 
18
24
  desc 'issue <user> <repo>', 'Lists all issue events for a given repository'
19
25
  def issue(user, repo)
20
- Event.issue user, repo, options[:params], options[:format]
26
+ global_options = options.dup
27
+ params = options[:params].dup
28
+ Util.hash_without!(global_options, params.keys + ['params'])
29
+ Event.issue user, repo, params, global_options
21
30
  end
22
31
 
23
32
  desc 'network <user> <repo>', 'Lists all public events for a network of repositories'
24
33
  def network(user, repo)
25
- Event.network user, repo, options[:params], options[:format]
34
+ global_options = options.dup
35
+ params = options[:params].dup
36
+ Util.hash_without!(global_options, params.keys + ['params'])
37
+ Event.network user, repo, params, global_options
26
38
  end
27
39
 
28
40
  desc 'org <org>', 'Lists all public events for an organization'
29
41
  def org(org)
30
- Event.organization org, options[:params], options[:format]
42
+ global_options = options.dup
43
+ params = options[:params].dup
44
+ Util.hash_without!(global_options, params.keys + ['params'])
45
+ Event.organization org, params, global_options
31
46
  end
32
47
 
33
48
  desc 'received <user>', 'Lists all events that a user has received'
@@ -39,9 +54,11 @@ module GithubCLI
39
54
  Otherwise, you’ll only see public events.
40
55
  DESC
41
56
  def received(user)
57
+ global_options = options.dup
42
58
  params = options[:params].dup
43
59
  params['public'] = options[:public] if options[:public]
44
- Event.received user, params, options[:format]
60
+ Util.hash_without!(global_options, params.keys + ['params'])
61
+ Event.received user, params, global_options
45
62
  end
46
63
 
47
64
  desc 'performed <user>', 'Lists all events that a user has performed'
@@ -52,9 +69,11 @@ module GithubCLI
52
69
  events. Otherwise, you’ll only see public events.
53
70
  DESC
54
71
  def performed(user)
72
+ global_options = options.dup
55
73
  params = options[:params].dup
56
74
  params['public'] = true if options[:public]
57
- Event.performed user, params, options[:format]
75
+ Util.hash_without!(global_options, params.keys + ['params'])
76
+ Event.performed user, params, global_options
58
77
  end
59
78
 
60
79
  desc 'user_org <user> <org>', "Lists all events for a user's organization"
@@ -63,7 +82,10 @@ module GithubCLI
63
82
  as the user to view this.
64
83
  DESC
65
84
  def user_org(user, org)
66
- Event.user_org user, org, options[:params], options[:format]
85
+ global_options = options.dup
86
+ params = options[:params].dup
87
+ Util.hash_without!(global_options, params.keys + ['params'])
88
+ Event.user_org user, org, params, global_options
67
89
  end
68
90
 
69
91
  end # Events
@@ -10,7 +10,10 @@ module GithubCLI
10
10
  :desc => 'List a <user> followers',
11
11
  :banner => '<user>'
12
12
  def list
13
- Follower.all options[:user], options[:params], options[:format]
13
+ global_options = options.dup
14
+ params = options[:params].dup
15
+ Util.hash_without!(global_options, params.keys + ['params', 'user'])
16
+ Follower.all options[:user], params, global_options
14
17
  end
15
18
 
16
19
  desc 'following', 'List who a user/the authenticated user is following'
@@ -18,22 +21,34 @@ module GithubCLI
18
21
  :desc => 'List who a <user> is following',
19
22
  :banner => '<user>'
20
23
  def following
21
- Follower.following options[:user], options[:params], options[:format]
24
+ global_options = options.dup
25
+ params = options[:params].dup
26
+ Util.hash_without!(global_options, params.keys + ['params', 'user'])
27
+ Follower.following options[:user], params, global_options
22
28
  end
23
29
 
24
30
  desc 'follower <user>', 'Check if you are following a user'
25
31
  def follower(user)
26
- Follower.follower user, options[:params], options[:format]
32
+ global_options = options.dup
33
+ params = options[:params].dup
34
+ Util.hash_without!(global_options, params.keys + ['params'])
35
+ Follower.follower user, params, global_options
27
36
  end
28
37
 
29
38
  desc 'follow <user>', 'Follow a user'
30
39
  def follow(user)
31
- Follower.follow user, options[:params], options[:format]
40
+ global_options = options.dup
41
+ params = options[:params].dup
42
+ Util.hash_without!(global_options, params.keys + ['params'])
43
+ Follower.follow user, params, global_options
32
44
  end
33
45
 
34
46
  desc 'unfollow <user>', 'Unfollow a user'
35
47
  def unfollow(user)
36
- Follower.unfollow user, options[:params], options[:format]
48
+ global_options = options.dup
49
+ params = options[:params].dup
50
+ Util.hash_without!(global_options, params.keys + ['params'])
51
+ Follower.unfollow user, params, global_options
37
52
  end
38
53
 
39
54
  end # Followers
@@ -17,20 +17,22 @@ module GithubCLI
17
17
  sort - newest, oldest, watchers, default: newest
18
18
  DESC
19
19
  def list(user, repo)
20
+ global_options = options.dup
20
21
  params = options[:params].dup
21
22
  params['sort'] = options[:sort] if options[:sort]
22
-
23
- Fork.all user, repo, params, options[:format]
23
+ Util.hash_without!(global_options, params.keys + ['params'])
24
+ Fork.all user, repo, params, global_options
24
25
  end
25
26
 
26
27
  option :org, :type => :string,
27
28
  :desc => 'Organization login. The repository will be forked into this organization.'
28
29
  desc 'create <user> <repo>', 'Create a new fork'
29
30
  def create(user, repo)
31
+ global_options = options.dup
30
32
  params = options[:params].dup
31
33
  params['organization'] = options[:org] if options[:org]
32
-
33
- Fork.create user, repo, params, options[:format]
34
+ Util.hash_without!(global_options, params.keys + ['params', 'org'])
35
+ Fork.create user, repo, params, global_options
34
36
  end
35
37
 
36
38
  end # Forks
@@ -10,21 +10,29 @@ module GithubCLI
10
10
  :desc => 'List a <user> gists'
11
11
  option :starred, :type => :boolean, :aliases => ["-s"], :default => false,
12
12
  :desc => 'List the authenticated users starred gists'
13
+ option :public, :type => :boolean,
14
+ :desc => "List all public gists"
13
15
  option :since, :type => :string, :banner => "timestamp",
14
16
  :desc => "a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ "
15
17
  def list
18
+ global_options = options.dup
19
+ params = options[:params].dup
16
20
  if options[:starred]
17
- Gist.starred options[:params], options[:format]
21
+ Util.hash_without!(global_options, params.keys + ['params', 'starred'])
22
+ Gist.starred params, global_options
18
23
  else
19
- params = options[:params].dup
20
24
  params['user'] = options[:user] if options[:user]
21
- Gist.all params, options[:format]
25
+ Util.hash_without!(global_options, params.keys + ['params', 'user'])
26
+ Gist.all params, global_options
22
27
  end
23
28
  end
24
29
 
25
30
  desc 'get <id>', 'Get a single gist'
26
31
  def get(id)
27
- Gist.get id, options[:params], options[:format]
32
+ global_options = options.dup
33
+ params = options[:params].dup
34
+ Util.hash_without!(global_options, params.keys + ['params'])
35
+ Gist.get id, params, global_options
28
36
  end
29
37
 
30
38
  option :public, :type => :boolean, :default => false
@@ -43,11 +51,13 @@ module GithubCLI
43
51
  content - Required string - File contents.
44
52
  DESC
45
53
  def create
54
+ global_options = options.dup
46
55
  params = options[:params].dup
47
56
  params['description'] = options[:desc] if options[:desc]
48
57
  params['public'] = options[:public] || false
49
- params['files'] = options[:files] if options[:files]
50
- Gist.create params, options[:format]
58
+ params['files'] = options[:files] if options[:files]
59
+ Util.hash_without!(global_options, params.keys + ['params', 'desc'])
60
+ Gist.create params, global_options
51
61
  end
52
62
 
53
63
  option :desc, :type => :string
@@ -65,35 +75,52 @@ module GithubCLI
65
75
  filename - Optional string - New name for this file.\n
66
76
  DESC
67
77
  def edit(id)
78
+ global_options = options.dup
68
79
  params = options[:params].dup
69
80
  params['description'] = options[:desc] if options[:desc]
70
81
  params['files'] = options[:files] if options[:files]
71
- Gist.edit id, params, options[:format]
82
+ Util.hash_without!(global_options, params.keys + ['params', 'desc'])
83
+ Gist.edit id, params, global_options
72
84
  end
73
85
 
74
86
  desc 'star <id>', 'Star a gist'
75
87
  def star(id)
76
- Gist.star id, options[:params], options[:format]
88
+ global_options = options.dup
89
+ params = options[:params].dup
90
+ Util.hash_without!(global_options, params.keys + ['params', 'desc'])
91
+ Gist.star id, params, global_options
77
92
  end
78
93
 
79
94
  desc 'unstar <id>', 'Unstar a gist'
80
95
  def unstar(id)
81
- Gist.unstar id, options[:params], options[:format]
96
+ global_options = options.dup
97
+ params = options[:params].dup
98
+ Util.hash_without!(global_options, params.keys + ['params', 'desc'])
99
+ Gist.unstar id, params, global_options
82
100
  end
83
101
 
84
102
  desc 'starred <id>', 'Check if a gist is starred'
85
103
  def starred(id)
86
- Gist.starred? id, options[:params], options[:format]
104
+ global_options = options.dup
105
+ params = options[:params].dup
106
+ Util.hash_without!(global_options, params.keys + ['params', 'desc'])
107
+ Gist.starred? id, params, global_options
87
108
  end
88
109
 
89
110
  desc 'fork <id>', 'Fork a gist'
90
111
  def fork(id)
91
- Gist.fork id, options[:params], options[:format]
112
+ global_options = options.dup
113
+ params = options[:params].dup
114
+ Util.hash_without!(global_options, params.keys + ['params', 'desc'])
115
+ Gist.fork id, params, global_options
92
116
  end
93
117
 
94
118
  desc 'delete <id>', 'Delete a gist'
95
119
  def delete(id)
96
- Gist.delete id, options[:params], options[:format]
120
+ global_options = options.dup
121
+ params = options[:params].dup
122
+ Util.hash_without!(global_options, params.keys + ['params', 'desc'])
123
+ Gist.delete id, params, global_options
97
124
  end
98
125
 
99
126
  end # Gists
@@ -81,7 +81,7 @@ module GithubCLI
81
81
  params['add_events'] = options[:add_events] if options[:add_events]
82
82
  params['remove_events'] = options[:remove_events] if options[:remove_events]
83
83
  params['active'] = options[:active] if options[:active]
84
- Util.hash_without!(global_options, %w[ params name config events add_events remove_events active ])
84
+ Util.hash_without!(global_options, params.keys + ['params'])
85
85
  Hook.edit user, repo, id, params, global_options
86
86
  end
87
87
 
@@ -56,6 +56,7 @@ module GithubCLI
56
56
  since - Optional string of a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ \n
57
57
  DESC
58
58
  def list
59
+ global_options = options.dup
59
60
  params = options[:params].dup
60
61
  params['org'] = options[:org] if options[:org]
61
62
  params['user'] = options[:user] if options[:user]
@@ -73,12 +74,18 @@ module GithubCLI
73
74
 
74
75
  arg = []
75
76
  arg = :user if !options[:all] && !(options[:user] || options[:org])
76
- Issue.all arg, params, options[:format]
77
+ Util.hash_without!(global_options, params.keys + ['params', 'all'])
78
+
79
+ Issue.all arg, params, global_options
77
80
  end
78
81
 
79
82
  desc 'get <user> <repo> <number>', 'Get a single issue'
80
83
  def get(user, repo, number)
81
- Issue.get user, repo, number, options[:params], options[:format]
84
+ global_options = options.dup
85
+ params = options[:params].dup
86
+ Util.hash_without!(global_options, params.keys + ['params'])
87
+
88
+ Issue.get user, repo, number, params, global_options
82
89
  end
83
90
 
84
91
  option :title, :type => :string, :required => true
@@ -104,14 +111,16 @@ module GithubCLI
104
111
  ghc issue create wycats thor --title='Found a bug'
105
112
  DESC
106
113
  def create(user, repo)
114
+ global_options = options.dup
107
115
  params = options[:params].dup
108
116
  params['title'] = options[:title]
109
117
  params['body'] = options[:body] if options[:body]
110
118
  params['assignee'] = options[:assignee] if options[:assignee]
111
119
  params['milestone'] = options[:milestone] if options[:milestone]
112
120
  params['labels'] = options[:labels] if options[:labels]
121
+ Util.hash_without!(global_options, params.keys + ['params'])
113
122
 
114
- Issue.create user, repo, params, options[:format]
123
+ Issue.create user, repo, params, global_options
115
124
  end
116
125
 
117
126
  option :title, :type => :string, :required => true
@@ -140,6 +149,7 @@ module GithubCLI
140
149
  ghc issue edit wycats thor 1 --title='Found a bug'
141
150
  DESC
142
151
  def edit(user, repo, number)
152
+ global_options = options.dup
143
153
  params = options[:params].dup
144
154
  params['title'] = options[:title]
145
155
  params['body'] = options[:body] if options[:body]
@@ -147,8 +157,9 @@ module GithubCLI
147
157
  params['milestone'] = options[:milestone] if options[:milestone]
148
158
  params['labels'] = options[:labels] if options[:labels]
149
159
  params['state'] = options[:state] if options[:state]
160
+ Util.hash_without!(global_options, params.keys + ['params'])
150
161
 
151
- Issue.edit user, repo, number, params, options[:format]
162
+ Issue.edit user, repo, number, params, global_options
152
163
  end
153
164
 
154
165
  end # Issues
@@ -7,12 +7,18 @@ module GithubCLI
7
7
 
8
8
  desc 'list <user> <repo>', 'Lists keys'
9
9
  def list(user, repo)
10
- Key.all 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
+ Key.all user, repo, params, global_options
11
14
  end
12
15
 
13
16
  desc 'get <user> <repo> <id>', 'Get a key'
14
17
  def get(user, repo, id)
15
- Key.get user, repo, id, options[:params], options[:format]
18
+ global_options = options.dup
19
+ params = options[:params].dup
20
+ Util.hash_without!(global_options, params.keys + ['params'])
21
+ Key.get user, repo, id, params, global_options
16
22
  end
17
23
 
18
24
  desc 'create <user> <repo>', 'Create a new key'
@@ -23,7 +29,10 @@ module GithubCLI
23
29
  key - Required string.
24
30
  DESC
25
31
  def create(user, repo)
26
- Key.create user, repo, options[:params], options[:format]
32
+ global_options = options.dup
33
+ params = options[:params].dup
34
+ Util.hash_without!(global_options, params.keys + ['params'])
35
+ Key.create user, repo, params, global_options
27
36
  end
28
37
 
29
38
  desc 'edit <user> <repo> <id>', 'Edit a key'
@@ -34,12 +43,18 @@ module GithubCLI
34
43
  key - Required string.
35
44
  DESC
36
45
  def edit(user, repo, id)
37
- Key.edit user, repo, id, options[:params], options[:format]
46
+ global_options = options.dup
47
+ params = options[:params].dup
48
+ Util.hash_without!(global_options, params.keys + ['params'])
49
+ Key.edit user, repo, id, params, global_options
38
50
  end
39
51
 
40
52
  desc 'delete <user> <repo> <id>', 'Delete a key'
41
53
  def delete(user, repo, id)
42
- Key.delete user, repo, id, options[:params], options[:format]
54
+ global_options = options.dup
55
+ params = options[:params].dup
56
+ Util.hash_without!(global_options, params.keys + ['params'])
57
+ Key.delete user, repo, id, params, global_options
43
58
  end
44
59
 
45
60
  end # Keys
@@ -6,27 +6,36 @@ module GithubCLI
6
6
  namespace :label
7
7
 
8
8
  desc 'list <user> <repo>', 'Listing all labels for this repository.'
9
- method_option :milestone, :type => :string, :aliases => ["-m"],
10
- :desc => 'List labels for every issue in a milestone.',
11
- :banner => '<milestone>'
12
- method_option :issue, :type => :string, :aliases => ["-i"],
13
- :desc => 'List labels on an issue.',
14
- :banner => '<issue>'
9
+ option :milestone, :type => :string, :aliases => ["-m"],
10
+ :banner => '<milestone>',
11
+ :desc => 'List labels for every issue in a milestone.'
12
+ option :issue, :type => :string, :aliases => ["-i"], :banner => '<issue>',
13
+ :desc => 'List labels on an issue.'
15
14
  def list(user, repo)
15
+ global_options = options.dup
16
16
  params = options[:params].dup
17
+ params_remove = params.keys + ['params']
17
18
  if (milestone_id = options[:milestone])
18
19
  params['milestone_id'] = milestone_id
20
+ params_remove << 'milestone'
19
21
  elsif (issue_id = options[:issue])
20
22
  params['issue_id'] = issue_id
23
+ params_remove << 'issue'
21
24
  end
22
- Label.all user, repo, params, options[:format]
25
+ Util.hash_without!(global_options, params_remove)
26
+ Label.all user, repo, params, global_options
23
27
  end
24
28
 
25
29
  desc 'get <user> <repo> <name>', 'Get a single label.'
26
30
  def get(user, repo, name)
27
- Label.get user, repo, name, options[:params], options[:format]
31
+ global_options = options.dup
32
+ params = options[:params].dup
33
+ Util.hash_without!(global_options, params.keys + ['params'])
34
+ Label.get user, repo, name, params, global_options
28
35
  end
29
36
 
37
+ option :name, :type => :string, :required => true
38
+ option :color, :type => :string, :required => true
30
39
  desc 'create <user> <repo>', 'Create a label.'
31
40
  long_desc <<-DESC
32
41
  Inputs
@@ -34,33 +43,63 @@ module GithubCLI
34
43
  color - Required string - 6 character hex code, without leading #
35
44
  DESC
36
45
  def create(user, repo)
37
- Label.create user, repo, options[:params], options[:format]
46
+ global_options = options.dup
47
+ params = options[:params].dup
48
+ params['name'] = options[:name] if options[:name]
49
+ params['color'] = options[:color] if options[:color]
50
+ Util.hash_without!(global_options, params.keys + ['params'])
51
+ Label.create user, repo, params, global_options
38
52
  end
39
53
 
54
+ option :name, :type => :string, :required => true
55
+ option :color, :type => :string, :required => true
40
56
  desc 'update <user> <repo> <name>', 'Update a label.'
57
+ long_desc <<-DESC
58
+ Inputs
59
+ name - Required string
60
+ color - Required string - 6 character hex code, without leading #
61
+ DESC
41
62
  def update(user, repo, name)
42
- Label.update user, repo, name, options[:params], options[:format]
63
+ global_options = options.dup
64
+ params = options[:params].dup
65
+ params['name'] = options[:name] if options[:name]
66
+ params['color'] = options[:color] if options[:color]
67
+ Util.hash_without!(global_options, params.keys + ['params'])
68
+ Label.update user, repo, name, params, global_options
43
69
  end
44
70
 
45
71
  desc 'delete <user> <repo> <name>', 'Delete a label.'
46
72
  def delete(user, repo, name)
47
- Label.delete user, repo, name, options[:params], options[:format]
73
+ global_options = options.dup
74
+ params = options[:params].dup
75
+ Util.hash_without!(global_options, params.keys + ['params'])
76
+ Label.delete user, repo, name, params, global_options
48
77
  end
49
78
 
50
79
  desc 'add <user> <repo> <number> <label>[<label>...]', 'Add labels to issue <number>.'
51
80
  def add(user, repo, number, *args)
52
- Label.add user, repo, number, args, options[:params], options[:format]
81
+ global_options = options.dup
82
+ params = options[:params].dup
83
+ Util.hash_without!(global_options, params.keys + ['params'])
84
+ Label.add user, repo, number, args, params, global_options
53
85
  end
54
86
 
55
87
  desc 'remove <user> <repo> [<name>/]<number>', 'Remove label<name> from an issue<number>'
56
88
  def remove(user, repo, number)
57
89
  name, number = Arguments.new(number).parse
58
- Label.remove user, repo, number, name, options[:params], options[:format]
90
+ global_options = options.dup
91
+ params = options[:params].dup
92
+ params['label_name'] = name if name
93
+ Util.hash_without!(global_options, params.keys + ['params'])
94
+ Label.remove user, repo, number, params, global_options
59
95
  end
60
96
 
61
97
  desc 'replace <user> <repo> <number> <label>[<label>...]', 'Replace all labels for an issue <number>.'
62
98
  def replace(user, repo, number, *args)
63
- Label.replace user, repo, number, args, options[:params], options[:format]
99
+ global_options = options.dup
100
+ params = options[:params].dup
101
+ Util.hash_without!(global_options, params.keys + ['params'])
102
+ Label.replace user, repo, number, args, params, global_options
64
103
  end
65
104
 
66
105
  end # Labels
@@ -19,22 +19,32 @@ module GithubCLI
19
19
  method_option :public, :type => :boolean, :default => false,
20
20
  :desc => 'List public members'
21
21
  def list(org)
22
+ global_options = options.dup
23
+ params = options[:params].dup
24
+ params_remove = params.keys + ['params']
25
+
22
26
  if options[:public]
23
- Member.all_public org, options[:params], options[:format]
24
- else
25
- Member.all org, options[:params], options[:format]
27
+ params['public'] = true
28
+ params_remove << 'public'
26
29
  end
30
+ Util.hash_without!(global_options, params_remove)
31
+ Member.all org, params, global_options
27
32
  end
28
33
 
29
34
  desc 'member [--public] <org> <user>', 'Checks if user is a member of an organization'
30
35
  method_option :public, :type => :boolean, :default => false,
31
36
  :desc => 'Get if a user is a public member of an organization'
32
37
  def member(org, user)
38
+ global_options = options.dup
39
+ params = options[:params].dup
40
+ params_remove = params.keys + ['params']
41
+
33
42
  if options[:public]
34
- Member.public_member? org, user, options[:params], options[:format]
35
- else
36
- Member.member? org, user, options[:params], options[:format]
43
+ params['public'] = true
44
+ params_remove << 'public'
37
45
  end
46
+ Util.hash_without!(global_options, params_remove)
47
+ Member.member? org, user, params, global_options
38
48
  end
39
49
 
40
50
  desc 'delete <org> <user>', 'Remove a member from an organization'
@@ -43,17 +53,26 @@ module GithubCLI
43
53
  will no longer have any access to the organization’s repositories.
44
54
  DESC
45
55
  def delete(org, user)
46
- Member.delete org, user, options[:params], options[:format]
56
+ global_options = options.dup
57
+ params = options[:params].dup
58
+ Util.hash_without!(global_options, params.keys + ['params'])
59
+ Member.delete org, user, params, global_options
47
60
  end
48
61
 
49
62
  desc 'publicize <org> <user>', "Publicize a user’s membership"
50
63
  def publicize(org, user)
51
- Member.publicize org, user, options[:params], options[:format]
64
+ global_options = options.dup
65
+ params = options[:params].dup
66
+ Util.hash_without!(global_options, params.keys + ['params'])
67
+ Member.publicize org, user, params, global_options
52
68
  end
53
69
 
54
70
  desc 'conceal <org> <user>', "Conceal a user’s membership"
55
71
  def conceal(org, user)
56
- Member.conceal org, user, options[:params], options[:format]
72
+ global_options = options.dup
73
+ params = options[:params].dup
74
+ Util.hash_without!(global_options, params.keys + ['params'])
75
+ Member.conceal org, user, params, global_options
57
76
  end
58
77
 
59
78
  end # Members
@@ -20,12 +20,13 @@ module GithubCLI
20
20
  commit_message - Optional String - Commit message to use for the merge commit. If omitted, a default message will be used.\n
21
21
  DESC
22
22
  def perform(user, repo)
23
+ global_options = options.dup
23
24
  params = options[:params].dup
24
25
  params['base'] = options[:base] if options[:base]
25
26
  params['head'] = options[:head] if options[:head]
26
27
  params['commit_message'] = options[:message] if options[:message]
27
-
28
- Merging.merge user, repo, params, options[:format]
28
+ Util.hash_without!(global_options, params.keys + ['params', 'commit_message'])
29
+ Merging.merge user, repo, params, global_options
29
30
  end
30
31
 
31
32
  end # Merging