github_cli 0.5.3 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. data/.travis.yml +14 -3
  2. data/CHANGELOG.md +15 -0
  3. data/Gemfile +1 -1
  4. data/Gemfile.lock +41 -44
  5. data/README.md +77 -14
  6. data/Rakefile +4 -2
  7. data/features/assignee.feature +1 -0
  8. data/features/blob.feature +1 -0
  9. data/features/collaborator.feature +1 -0
  10. data/features/commit.feature +2 -1
  11. data/features/config.feature +27 -28
  12. data/features/event.feature +1 -0
  13. data/features/init.feature +20 -23
  14. data/features/key.feature +5 -5
  15. data/features/milestone.feature +3 -2
  16. data/features/reference.feature +3 -2
  17. data/features/starring.feature +1 -0
  18. data/features/support/hooks.rb +1 -1
  19. data/features/tag.feature +2 -1
  20. data/features/tree.feature +17 -0
  21. data/features/watching.feature +1 -0
  22. data/fixtures/simple_config +3 -5
  23. data/github_cli.gemspec +1 -1
  24. data/lib/github_cli/api.rb +11 -6
  25. data/lib/github_cli/apis/event.rb +8 -8
  26. data/lib/github_cli/apis/label.rb +0 -12
  27. data/lib/github_cli/apis/starring.rb +5 -5
  28. data/lib/github_cli/apis/watching.rb +5 -5
  29. data/lib/github_cli/cli.rb +21 -30
  30. data/lib/github_cli/command.rb +1 -1
  31. data/lib/github_cli/commands/authorizations.rb +28 -2
  32. data/lib/github_cli/commands/collaborators.rb +12 -12
  33. data/lib/github_cli/commands/commits.rb +18 -2
  34. data/lib/github_cli/commands/events.rb +6 -8
  35. data/lib/github_cli/commands/followers.rb +1 -1
  36. data/lib/github_cli/commands/labels.rb +22 -20
  37. data/lib/github_cli/commands/milestones.rb +43 -13
  38. data/lib/github_cli/commands/references.rb +21 -6
  39. data/lib/github_cli/commands/starring.rb +3 -2
  40. data/lib/github_cli/commands/tags.rb +16 -1
  41. data/lib/github_cli/commands/trees.rb +11 -5
  42. data/lib/github_cli/commands/watching.rb +3 -2
  43. data/lib/github_cli/config.rb +15 -6
  44. data/lib/github_cli/dsl.rb +2 -2
  45. data/lib/github_cli/formatter.rb +2 -3
  46. data/lib/github_cli/formatters/csv.rb +29 -14
  47. data/lib/github_cli/formatters/table.rb +2 -3
  48. data/lib/github_cli/man/gcli-config.1 +17 -13
  49. data/lib/github_cli/man/gcli-config.1.txt +23 -21
  50. data/lib/github_cli/vendor/thor/actions/create_link.rb +3 -0
  51. data/lib/github_cli/vendor/thor/actions/directory.rb +29 -10
  52. data/lib/github_cli/vendor/thor/actions/file_manipulation.rb +9 -3
  53. data/lib/github_cli/vendor/thor/actions.rb +18 -18
  54. data/lib/github_cli/vendor/thor/base.rb +97 -89
  55. data/lib/github_cli/vendor/thor/{task.rb → command.rb} +16 -12
  56. data/lib/github_cli/vendor/thor/core_ext/hash_with_indifferent_access.rb +5 -0
  57. data/lib/github_cli/vendor/thor/core_ext/io_binary_read.rb +12 -0
  58. data/lib/github_cli/vendor/thor/error.rb +4 -7
  59. data/lib/github_cli/vendor/thor/group.rb +34 -32
  60. data/lib/github_cli/vendor/thor/invocation.rb +28 -26
  61. data/lib/github_cli/vendor/thor/parser/options.rb +66 -26
  62. data/lib/github_cli/vendor/thor/rake_compat.rb +3 -2
  63. data/lib/github_cli/vendor/thor/runner.rb +21 -20
  64. data/lib/github_cli/vendor/thor/shell/basic.rb +20 -16
  65. data/lib/github_cli/vendor/thor/shell/color.rb +13 -9
  66. data/lib/github_cli/vendor/thor/shell/html.rb +13 -9
  67. data/lib/github_cli/vendor/thor/util.rb +214 -210
  68. data/lib/github_cli/vendor/thor/version.rb +1 -1
  69. data/lib/github_cli/vendor/thor.rb +232 -153
  70. data/lib/github_cli/version.rb +1 -1
  71. data/man/gcli-config.1.ronn +14 -11
  72. data/spec/github_cli/commands/assignees_spec.rb +20 -0
  73. data/spec/github_cli/commands/blobs_spec.rb +21 -0
  74. data/spec/github_cli/commands/collaborators_spec.rb +31 -0
  75. data/spec/github_cli/commands/commits_spec.rb +26 -0
  76. data/spec/github_cli/commands/emails_spec.rb +24 -0
  77. data/spec/github_cli/commands/events_spec.rb +56 -0
  78. data/spec/github_cli/commands/followers_spec.rb +44 -0
  79. data/spec/github_cli/commands/keys_spec.rb +36 -0
  80. data/spec/github_cli/commands/labels_spec.rb +61 -0
  81. data/spec/github_cli/commands/milestones_spec.rb +47 -0
  82. data/spec/github_cli/commands/references_spec.rb +42 -0
  83. data/spec/github_cli/commands/starring_spec.rb +40 -0
  84. data/spec/github_cli/commands/tags_spec.rb +26 -0
  85. data/spec/github_cli/commands/trees_spec.rb +32 -0
  86. data/spec/github_cli/commands/watching_spec.rb +40 -0
  87. data/spec/github_cli/config_spec.rb +109 -116
  88. data/spec/github_cli/util/convert_value_spec.rb +19 -0
  89. data/spec/github_cli/util/convert_values_spec.rb +14 -0
  90. data/spec/github_cli/util_spec.rb +0 -29
  91. metadata +51 -19
  92. data/lib/github_cli/vendor/thor/core_ext/dir_escape.rb +0 -0
  93. data/lib/github_cli/vendor/thor/core_ext/file_binary_read.rb +0 -9
  94. data/lib/github_cli/vendor/thor/empty.txt +0 -0
@@ -1,5 +1,6 @@
1
1
  Feature: gcli tree
2
2
 
3
+ @ci-run
3
4
  Scenario: Available commands
4
5
 
5
6
  When I run `gcli tree`
@@ -14,3 +15,19 @@ Feature: gcli tree
14
15
  """
15
16
  When I run `gcli tree get wycats thor 827efc6d5`
16
17
  Then the exit status should be 0
18
+
19
+ Scenario: Get tree recursively
20
+ Given the GitHub API server:
21
+ """
22
+ get('/repos/wycats/thor/git/trees/827efc6d5') { status 200 }
23
+ """
24
+ When I run `gcli tree get wycats thor 827efc6d5 --recursive`
25
+ Then the exit status should be 0
26
+
27
+ Scenario: Create tree
28
+ Given the Github API server:
29
+ """
30
+ post('/repos/wycats/thor/git/trees') { status 200 }
31
+ """
32
+ When I run `gcli tree create wycats thor --tree='path:file1 mode:00111'`
33
+ Then the exit status should be 0
@@ -1,5 +1,6 @@
1
1
  Feature: gcli watching
2
2
 
3
+ @ci-run
3
4
  Scenario: Available commands
4
5
 
5
6
  When I run `gcli watch`
@@ -1,9 +1,7 @@
1
1
  ---
2
- auth.token: ad7f9asdf97as98df7as9fd7
3
- auth.basic: 'login:password'
4
- core.host:
5
- core.user:
6
- core.repo:
2
+ user.token: ad7f9asdf97as98df7as9fd7
3
+ user.login: login
4
+ user.password: password
7
5
  commands.issue.list:
8
6
  title: 'ticket'
9
7
  commands.issue.get:
data/github_cli.gemspec CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
17
17
  gem.require_paths = ["lib"]
18
18
  gem.version = GithubCLI::VERSION
19
19
 
20
- gem.add_dependency 'github_api', '~> 0.7'
20
+ gem.add_dependency 'github_api', '~> 0.9'
21
21
 
22
22
  gem.add_development_dependency 'rspec'
23
23
  gem.add_development_dependency 'aruba'
@@ -1,11 +1,10 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module GithubCLI
4
+
4
5
  # The API class is the main entry point for creating GithubCLI APIs.
5
6
  class API
6
7
 
7
- ENDPOINT = ''
8
-
9
8
  @@api = nil
10
9
 
11
10
  class << self
@@ -20,9 +19,15 @@ module GithubCLI
20
19
 
21
20
  def configure_api
22
21
  @@api = Github.new
23
- @@api.oauth_token = GithubCLI.config['auth.token']
24
- @@api.basic_auth = GithubCLI.config['auth.basic']
25
- @@api.endpoint = GithubCLI.config['core.endpoint'] || @@api.endpoint
22
+ config = GithubCLI.config.data
23
+
24
+ if config['user.token']
25
+ @@api.oauth_token = config['user.token']
26
+ end
27
+ if config['user.login'] && config['user.password']
28
+ @@api.basic_auth = "#{config['user.login']}:#{config['user.password']}"
29
+ end
30
+ @@api.endpoint = GithubCLI.config['core.endpoint'] || @@api.endpoint
26
31
  if ENV['TEST_HOST']
27
32
  @@api.endpoint = 'http://' + ENV['TEST_HOST']
28
33
  end
@@ -30,7 +35,7 @@ module GithubCLI
30
35
  end
31
36
 
32
37
  def output(format=:table, &block)
33
- response = block.call
38
+ response = block.call
34
39
  formatter = Formatter.new response, :format => format
35
40
  formatter.render_output
36
41
  end
@@ -7,49 +7,49 @@ module GithubCLI
7
7
 
8
8
  def public(params, format)
9
9
  output format do
10
- github_api.events.public params
10
+ github_api.activity.events.public params
11
11
  end
12
12
  end
13
13
 
14
14
  def repository(user, repo, params, format)
15
15
  output format do
16
- github_api.events.repository user, repo, params
16
+ github_api.activity.events.repository user, repo, params
17
17
  end
18
18
  end
19
19
 
20
20
  def issue(user, repo, params, format)
21
21
  output format do
22
- github_api.events.issue user, repo, params
22
+ github_api.activity.events.issue user, repo, params
23
23
  end
24
24
  end
25
25
 
26
26
  def network(user, repo, params, format)
27
27
  output format do
28
- github_api.events.network user, repo, params
28
+ github_api.activity.events.network user, repo, params
29
29
  end
30
30
  end
31
31
 
32
32
  def organization(org, params, format)
33
33
  output format do
34
- github_api.events.organization org, params
34
+ github_api.activity.events.organization org, params
35
35
  end
36
36
  end
37
37
 
38
38
  def received(user, params, format)
39
39
  output format do
40
- github_api.events.received user, params
40
+ github_api.activity.events.received user, params
41
41
  end
42
42
  end
43
43
 
44
44
  def performed(user, params, format)
45
45
  output format do
46
- github_api.events.performed user, params
46
+ github_api.activity.events.performed user, params
47
47
  end
48
48
  end
49
49
 
50
50
  def user_org(user, org, params, format)
51
51
  output format do
52
- github_api.events.user_org user, org, params
52
+ github_api.activity.events.user_org user, org, params
53
53
  end
54
54
  end
55
55
  end
@@ -35,12 +35,6 @@ module GithubCLI
35
35
  end
36
36
  end
37
37
 
38
- def issue(user, repo, issue_id, params, format)
39
- output format do
40
- github_api.issues.labels.issue user, repo, issue_id, params
41
- end
42
- end
43
-
44
38
  def add(user, repo, issue_id, *args)
45
39
  format, params = args.pop, args.pop
46
40
 
@@ -62,12 +56,6 @@ module GithubCLI
62
56
  github_api.issues.labels.replace user, repo, issue_id, args.flatten, params
63
57
  end
64
58
  end
65
-
66
- def milestone(user, repo, number, params, format)
67
- output format do
68
- github_api.issues.labels.milestone user, repo, number, params
69
- end
70
- end
71
59
  end
72
60
 
73
61
  end # Label
@@ -7,31 +7,31 @@ module GithubCLI
7
7
 
8
8
  def list(user, repo, params, format)
9
9
  output format do
10
- github_api.repos.starring.list user, repo, params
10
+ github_api.activity.starring.list user, repo, params
11
11
  end
12
12
  end
13
13
 
14
14
  def starred(params, format)
15
15
  output format do
16
- github_api.repos.starring.starred params
16
+ github_api.activity.starring.starred params
17
17
  end
18
18
  end
19
19
 
20
20
  def starring?(user, repo, params, format)
21
21
  output format do
22
- github_api.repos.starring.starring? user, repo, params
22
+ github_api.activity.starring.starring? user, repo, params
23
23
  end
24
24
  end
25
25
 
26
26
  def star(user, repo, params, format)
27
27
  output format do
28
- github_api.repos.starring.star user, repo, params
28
+ github_api.activity.starring.star user, repo, params
29
29
  end
30
30
  end
31
31
 
32
32
  def unstar(user, repo, params, format)
33
33
  output format do
34
- github_api.repos.starring.unstar user, repo, params
34
+ github_api.activity.starring.unstar user, repo, params
35
35
  end
36
36
  end
37
37
  end
@@ -7,31 +7,31 @@ module GithubCLI
7
7
 
8
8
  def list(user, repo, params, format)
9
9
  output format do
10
- github_api.repos.watching.list user, repo, params
10
+ github_api.activity.watching.list user, repo, params
11
11
  end
12
12
  end
13
13
 
14
14
  def watched(params, format)
15
15
  output format do
16
- github_api.repos.watching.watched params
16
+ github_api.activity.watching.watched params
17
17
  end
18
18
  end
19
19
 
20
20
  def watching?(user, repo, params, format)
21
21
  output format do
22
- github_api.repos.watching.watching? user, repo, params
22
+ github_api.activity.watching.watching? user, repo, params
23
23
  end
24
24
  end
25
25
 
26
26
  def start(user, repo, params, format)
27
27
  output format do
28
- github_api.repos.watching.watch user, repo, params
28
+ github_api.activity.watching.watch user, repo, params
29
29
  end
30
30
  end
31
31
 
32
32
  def stop(user, repo, params, format)
33
33
  output format do
34
- github_api.repos.watching.unwatch user, repo, params
34
+ github_api.activity.watching.unwatch user, repo, params
35
35
  end
36
36
  end
37
37
  end
@@ -24,8 +24,8 @@ module GithubCLI
24
24
 
25
25
  map ALIASES
26
26
 
27
- class_option :config, :type => :string,
28
- :desc => "Configuration file.", :banner => "<filename>",
27
+ class_option :filename, :type => :string,
28
+ :desc => "Configuration file name.", :banner => "<filename>",
29
29
  :default => ".githubrc"
30
30
  class_option :token, :type => :string,
31
31
  :desc => 'Authentication token.',
@@ -45,18 +45,23 @@ module GithubCLI
45
45
  no_tasks do
46
46
  def defaults
47
47
  {
48
- 'auth.token' => nil,
49
- 'auth.basic' => nil,
50
- 'auth.login' => nil,
51
- 'auth.password' => nil,
52
- 'core.endpoint' => nil,
48
+ 'user.token' => nil,
49
+ 'user.login' => nil,
50
+ 'user.password' => nil,
51
+ 'user.name' => nil,
52
+ 'user.repo' => nil,
53
+ 'user.org' => nil,
54
+ 'core.adapter' => :net_http,
55
+ 'core.endpoint' => 'https://api.github.com',
56
+ 'core.ssl' => nil,
57
+ 'core.mime' => :json,
53
58
  'core.editor' => 'vi',
54
59
  'core.pager' => 'less',
55
60
  'core.no-pager' => false,
56
61
  'core.no-color' => false,
57
- 'core.format' => 'csv',
58
- 'core.auto' => false,
59
- 'core.aliases' => {}
62
+ 'core.format' => 'table',
63
+ 'core.auto_pagination' => false,
64
+ 'core.aliases' => nil,
60
65
  }
61
66
  end
62
67
  end
@@ -72,18 +77,11 @@ module GithubCLI
72
77
  DESC
73
78
  method_option :force, :type => :boolean, :default => false, :aliases => "-f",
74
79
  :banner => "Overwrite configuration file. "
75
- method_option :global, :type => :boolean, :default => false,
76
- :desc => 'Create global config file'
77
80
  method_option :local, :type => :boolean, :default => false,
78
- :desc => 'Create local config file'
81
+ :desc => 'Create local configuration file, otherwise a global configuration file in user home is created.'
79
82
  def init(filename=nil)
80
- config_filename = (filename.nil? || filename =~ /^\//)? options[:config] : filename
81
-
82
- if !options[:global] and !options[:local]
83
- GithubCLI.ui.error 'Invalid scope given. Please use --local or --global.'
84
- exit 1
85
- end
86
-
83
+ config_filename = filename ? filename : options[:filename]
84
+ GithubCLI.config.filename = config_filename
87
85
  GithubCLI.config.location = options[:local] ? 'local' : 'global'
88
86
 
89
87
  if File.exists?(GithubCLI.config.path) && !options[:force]
@@ -91,8 +89,7 @@ module GithubCLI
91
89
  exit 1
92
90
  end
93
91
 
94
- oauth_token = ask "Please specify your GitHub Authentication Token (register on github.com to get it):"
95
- GithubCLI.config.save(defaults.merge({'auth.token' => oauth_token}))
92
+ GithubCLI.config.save(defaults)
96
93
  GithubCLI.ui.confirm "Writing new configuration file to #{GithubCLI.config.path}"
97
94
  end
98
95
 
@@ -106,8 +103,6 @@ module GithubCLI
106
103
  There two types of config files, global and project specific. When modifying
107
104
  options ensure that you modifying the correct config.
108
105
  DESC
109
- method_option :global, :type => :boolean, :default => false,
110
- :desc => 'use global config file'
111
106
  method_option :local, :type => :boolean, :default => false,
112
107
  :desc => 'use local config file'
113
108
  method_option :list, :type => :boolean, :default => false, :aliases => '-l',
@@ -116,14 +111,10 @@ module GithubCLI
116
111
  :desc => 'opens an editor'
117
112
  def config(*args)
118
113
  name, value = args.shift, args.shift
119
-
120
114
  GithubCLI.config.location = options[:local] ? 'local' : 'global'
121
115
 
122
- if !options[:global] and !options[:local]
123
- GithubCLI.ui.error 'Invalid scope given. Please use --local or --global.'
124
- exit 1
125
- elsif !File.exists?(GithubCLI.config.path)
126
- GithubCLI.ui.error "#{GithubCLI.config.location} configuration file does not exist. Please use `#{GithubCLI.executable_name} init --#{GithubCLI.config.location}`"
116
+ if !File.exists?(GithubCLI.config.path)
117
+ GithubCLI.ui.error "Configuration file does not exist. Please use `#{GithubCLI.executable_name} init` to create one."
127
118
  exit 1
128
119
  end
129
120
 
@@ -58,7 +58,7 @@ module GithubCLI
58
58
  Thor::Base.subclasses.each do |klass|
59
59
  namespace = extract_namespace(klass)
60
60
  next unless is_api_command?(namespace)
61
- namespace = "" if namespace.index API_CLASSES.first
61
+ namespace = "" if namespace.index(API_CLASSES.first)
62
62
 
63
63
  klass.tasks.each do |task|
64
64
  next if task.last.name.index HELP_COMMAND
@@ -22,6 +22,12 @@ module GithubCLI
22
22
  end
23
23
 
24
24
  desc 'create', 'Create a new authorization'
25
+ option :scopes, :type => :array, :banner => "user public_repo repo...",
26
+ :desc => "A list of scopes that this authorization is in."
27
+ option :note, :type => :string,
28
+ :desc => "A note to remind you what the OAuth token is for."
29
+ option :note_url, :type => :string,
30
+ :desc => "A URL to remind you what the OAuth token is for."
25
31
  long_desc <<-DESC
26
32
  You can only create your own token, and only through Basic Authentication.\n
27
33
 
@@ -32,10 +38,24 @@ module GithubCLI
32
38
  note_url - Optional string - A URL to remind you what the OAuth token is for.
33
39
  DESC
34
40
  def create
35
- Authorization.create options[:params], options[:format]
41
+ params = options[:params].dup
42
+ params['scopes'] = options[:scopes] if options[:scopes]
43
+ params['note'] = options[:note] if options[:note]
44
+ params['note_url'] = options[:note_url] if options[:note_url]
45
+ Authorization.create params, options[:format]
36
46
  end
37
47
 
38
48
  desc 'update <id>', 'Update an existing authorization'
49
+ option :scopes, :type => :array, :banner => "user public_repo repo...",
50
+ :desc => "A list of scopes that this authorization is in."
51
+ option :add_scopes, :type => :array,
52
+ :desc => "A list of scopes to add to this authorization."
53
+ option :remove_scopes, :type => :array,
54
+ :desc => "A list of scopes to remove from this authorization."
55
+ option :note, :type => :string,
56
+ :desc => "A note to remind you what the OAuth token is for."
57
+ option :note_url, :type => :string,
58
+ :desc => "A URL to remind you what the OAuth token is for."
39
59
  long_desc <<-DESC
40
60
  Inputs
41
61
 
@@ -46,7 +66,13 @@ module GithubCLI
46
66
  note_url - Optional string - A URL to remind you what the OAuth token is for.
47
67
  DESC
48
68
  def update(id)
49
- Authorization.update id, options[:params], options[:format]
69
+ params = options[:params].dup
70
+ params['scopes'] = options[:scopes] if options[:scopes]
71
+ params['add_scopes'] = options[:add_scopes] if options[:add_scopes]
72
+ params['remove_scopes'] = options[:remove_scopes] if options[:remove_scopes]
73
+ params['note'] = options[:note] if options[:note]
74
+ params['note_url'] = options[:note_url] if options[:note_url]
75
+ Authorization.update id, params, options[:format]
50
76
  end
51
77
 
52
78
  desc 'delete <id>', 'Delete an authorization'
@@ -5,24 +5,24 @@ module GithubCLI
5
5
 
6
6
  namespace :collab
7
7
 
8
- desc 'list <user> <repo>', 'Lists collaborators'
9
- def list(user, repo)
10
- Collaborator.all user, repo, options[:params], options[:format]
8
+ desc 'list <owner> <repo>', 'Lists collaborators'
9
+ def list(owner, repo)
10
+ Collaborator.all owner, repo, options[:params], options[:format]
11
11
  end
12
12
 
13
- desc 'add <user> <repo> <collab>', 'Add a collaborator'
14
- def add(user, repo, collab)
15
- Collaborator.add user, repo, collab, options[:params], options[:format]
13
+ desc 'add <owner> <repo> <user>', 'Add a collaborator'
14
+ def add(owner, repo, user)
15
+ Collaborator.add owner, repo, user, options[:params], options[:format]
16
16
  end
17
17
 
18
- desc 'collab <user> <repo> <collab>', 'Checks if user is a collaborator on a given repo'
19
- def collab(user, repo, collab)
20
- Collaborator.collaborator? user, repo, collab, options[:params], options[:format]
18
+ desc 'collab <owner> <repo> <user>', 'Checks if user is a collaborator on a given repo'
19
+ def collab(owner, repo, user)
20
+ Collaborator.collaborator? owner, repo, user, options[:params], options[:format]
21
21
  end
22
22
 
23
- desc 'remove <user> <repo> <id>', 'Remove a collaborator'
24
- def remove(user, repo, collab)
25
- Collaborator.remove user, repo, collab, options[:params], options[:format]
23
+ desc 'remove <owner> <repo> <user>', 'Remove a collaborator'
24
+ def remove(owner, repo, user)
25
+ Collaborator.remove owner, repo, user, options[:params], options[:format]
26
26
  end
27
27
 
28
28
  end # Collaborators
@@ -11,6 +11,16 @@ module GithubCLI
11
11
  end
12
12
 
13
13
  desc 'create <user> <repo>', 'Create a Commit'
14
+ option :message, :type => :string, :aliases => ["-m"],
15
+ :desc => "String of the commit message."
16
+ option :tree, :type => :string, :aliases => ["-t"], :banner => "<sha>",
17
+ :desc => "String of the SHA of the tree object this commit points to."
18
+ option :parents, :type => :array, :banner => "<sha1> <sha2> ...",
19
+ :desc => "Array of the SHAs of the commits that were the parents of this commit. "
20
+ option :author, :type => :hash,
21
+ :desc => "If the author section is omitted, it will be filled in with the authenticated user’s information and the current date."
22
+ option :committer, :type => :hash,
23
+ :desc => "The committer section is optional and will be filled with the author data if omitted."
14
24
  long_desc <<-DESC
15
25
  Parameters
16
26
 
@@ -27,10 +37,16 @@ module GithubCLI
27
37
  author.date - Timestamp of when this commit was authored \n
28
38
  committer.name - String of the name of the committer of the commit \n
29
39
  committer.email - String of the email of the committer of the commit \n
30
- committer.date:: Timestamp of when this commit was committed
40
+ committer.date - Timestamp of when this commit was committed
31
41
  DESC
32
42
  def create(user, repo)
33
- Commit.create user, repo, options[:params], options[:format]
43
+ params = options[:params].dup
44
+ params['message'] = options[:message] if options[:message]
45
+ params['tree'] = options[:tree] if options[:tree]
46
+ params['parents'] = options[:parents] if options[:parents]
47
+ params['author'] = options[:author] if options[:author]
48
+ params['committer'] = options[:committer] if options[:committer]
49
+ Commit.create user, repo, params, options[:format]
34
50
  end
35
51
 
36
52
  end # Commit
@@ -39,10 +39,9 @@ module GithubCLI
39
39
  Otherwise, you’ll only see public events.
40
40
  DESC
41
41
  def received(user)
42
- if options[:public]
43
- options[:params]['public'] = true
44
- end
45
- Event.received user, options[:params], options[:format]
42
+ params = options[:params].dup
43
+ params['public'] = options[:public] if options[:public]
44
+ Event.received user, params, options[:format]
46
45
  end
47
46
 
48
47
  desc 'performed <user>', 'Lists all events that a user has performed'
@@ -53,10 +52,9 @@ module GithubCLI
53
52
  events. Otherwise, you’ll only see public events.
54
53
  DESC
55
54
  def performed(user)
56
- if options[:public]
57
- options[:params]['public'] = true
58
- end
59
- Event.performed user, options[:params], options[:format]
55
+ params = options[:params].dup
56
+ params['public'] = true if options[:public]
57
+ Event.performed user, params, options[:format]
60
58
  end
61
59
 
62
60
  desc 'user_org <user> <org>', "Lists all events for a user's organization"
@@ -13,7 +13,7 @@ module GithubCLI
13
13
  Follower.all options[:user], options[:params], options[:format]
14
14
  end
15
15
 
16
- desc 'following', 'List who the authenticated user is following'
16
+ desc 'following', 'List who a user/the authenticated user is following'
17
17
  method_option :user, :type => :string, :aliases => ["-u"],
18
18
  :desc => 'List who a <user> is following',
19
19
  :banner => '<user>'
@@ -6,8 +6,20 @@ 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
15
  def list(user, repo)
10
- Label.all user, repo, options[:params], options[:format]
16
+ params = options[:params].dup
17
+ if (milestone_id = options[:milestone])
18
+ params['milestone_id'] = milestone_id
19
+ elsif (issue_id = options[:issue])
20
+ params['issue_id'] = issue_id
21
+ end
22
+ Label.all user, repo, params, options[:format]
11
23
  end
12
24
 
13
25
  desc 'get <user> <repo> <name>', 'Get a single label.'
@@ -35,30 +47,20 @@ module GithubCLI
35
47
  Label.delete user, repo, name, options[:params], options[:format]
36
48
  end
37
49
 
38
- desc 'issue <user> <repo> <number>', 'List labels on an issue.'
39
- def issue(user, repo, number)
40
- Label.issue user, repo, number, options[:params], options[:format]
50
+ desc 'add <user> <repo> <number> <label>[<label>...]', 'Add labels to issue <number>.'
51
+ def add(user, repo, number, *args)
52
+ Label.add user, repo, number, args, options[:params], options[:format]
41
53
  end
42
54
 
43
- desc 'add <user> <repo> <issue_id> <label>[<label>...]', 'Add labels to <issue_id>.'
44
- def add(user, repo, issue_id, *args)
45
- Label.add user, repo, issue_id, args, options[:params], options[:format]
46
- end
47
-
48
- desc 'remove <user> <repo> [<label_id>/]<issue_id>', 'Remove <label_id> from an <issue_id>'
55
+ desc 'remove <user> <repo> [<name>/]<number>', 'Remove label<name> from an issue<number>'
49
56
  def remove(user, repo, number)
50
- label_id, issue_id = Arguments.new(number).parse
51
- Label.remove user, repo, issue_id, label_id, options[:params], options[:format]
52
- end
53
-
54
- desc 'replace <user> <repo> <issue_id> <label>[<label>...]', 'Replace all labels for an <issue_id>.'
55
- def replace(user, repo, issue_id, *args)
56
- Label.replace user, repo, issue_id, args, options[:params], options[:format]
57
+ name, number = Arguments.new(number).parse
58
+ Label.remove user, repo, number, name, options[:params], options[:format]
57
59
  end
58
60
 
59
- desc 'milestone <user> <repo> <number>', 'Get labels for every issue in a milestone.'
60
- def milestone(user, repo, number)
61
- Label.milestone user, repo, number, options[:params], options[:format]
61
+ desc 'replace <user> <repo> <number> <label>[<label>...]', 'Replace all labels for an issue <number>.'
62
+ def replace(user, repo, number, *args)
63
+ Label.replace user, repo, number, args, options[:params], options[:format]
62
64
  end
63
65
 
64
66
  end # Labels