github_cli 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ 0.5.5 (March 30, 2013)
2
+
3
+ * Change PullRequest commands to take specific options and add tests
4
+ * Change to stop formatting response without body
5
+ * Change Repository commands to take specific options and add tests
6
+ * Add repo branch & delete commands
7
+ * Change Gist commands to take specific options and add tests
8
+
1
9
  0.5.4 (March 23, 2013)
2
10
 
3
11
  * Update vendor dependency
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- github_cli (0.5.4)
4
+ github_cli (0.5.5)
5
5
  github_api (~> 0.9)
6
6
 
7
7
  GEM
data/bin/gcli CHANGED
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
+
3
+ Signal.trap("INT") { exit 1 }
4
+
2
5
  lib_dir = File.expand_path("../../lib", __FILE__)
3
6
  $LOAD_PATH.unshift lib_dir if File.directory?(lib_dir)
4
7
 
@@ -52,3 +52,4 @@ Feature: Configuration file
52
52
  Given I run `gcli init`
53
53
  When I run `gcli config -l`
54
54
  Then the stdout should contain "user.token"
55
+
@@ -1,5 +1,6 @@
1
1
  Feature: gcli email
2
2
 
3
+ @ci-run
3
4
  Scenario: Available commands
4
5
 
5
6
  When I run `gcli email`
@@ -1,5 +1,6 @@
1
1
  Feature: gcli follower
2
2
 
3
+ @ci-run
3
4
  Scenario: Available commands
4
5
 
5
6
  When I run `gcli follower`
@@ -1,5 +1,6 @@
1
1
  Feature: gcli gist
2
2
 
3
+ @ci-run
3
4
  Scenario: Available commands
4
5
 
5
6
  When I run `gcli gist`
data/features/key.feature CHANGED
@@ -1,6 +1,6 @@
1
1
  Feature: gcli key
2
2
 
3
- @commands
3
+ @ci-run
4
4
  Scenario: Available commands
5
5
  When I run `gcli key`
6
6
  Then the exit status should be 0
@@ -13,7 +13,7 @@ Feature: gcli key
13
13
  Scenario: List keys
14
14
  Given the GitHub API server:
15
15
  """
16
- get('/repos/wycats/thor/keys') { json [{:key => "ssh"}] }
16
+ get('/repos/wycats/thor/keys') { status 200 }
17
17
  """
18
18
  When I run `gcli key ls wycats thor`
19
19
  Then the exit status should be 0
@@ -21,7 +21,7 @@ Feature: gcli key
21
21
  Scenario: Get key
22
22
  Given the GitHub API server:
23
23
  """
24
- get('/repos/wycats/thor/keys/1') { json :key => "ssh" }
24
+ get('/repos/wycats/thor/keys/1') { status 200 }
25
25
  """
26
26
  When I run `gcli key get wycats thor 1`
27
27
  Then the exit status should be 0
@@ -29,7 +29,7 @@ Feature: gcli key
29
29
  Scenario: Create key
30
30
  Given the GitHub API server:
31
31
  """
32
- post('/repos/wycats/thor/keys') { json :key => "ssh" }
32
+ post('/repos/wycats/thor/keys') { status 200 }
33
33
  """
34
34
  When I run `gcli key create wycats thor --params=title:octo key:fh34d55`
35
35
  Then the exit status should be 0
@@ -37,7 +37,7 @@ Feature: gcli key
37
37
  Scenario: Edit key
38
38
  Given the GitHub API server:
39
39
  """
40
- patch('/repos/wycats/thor/keys/1') { json :key => "ssh" }
40
+ patch('/repos/wycats/thor/keys/1') { status 200 }
41
41
  """
42
42
  When I run `gcli key edit wycats thor 1 --params=title:octo key:fh34d55`
43
43
  Then the exit status should be 0
@@ -1,5 +1,6 @@
1
1
  Feature: gcli pull request
2
2
 
3
+ @ci-run
3
4
  Scenario: Available commands
4
5
 
5
6
  When I run `gcli pull`
@@ -1,19 +1,30 @@
1
1
  Feature: gcli repository
2
2
 
3
+ @ci-run
3
4
  Scenario: Available commands
4
5
  When I run `gcli repo`
5
6
  Then the exit status should be 0
7
+ And the output should contain "gcli repo branch"
6
8
  And the output should contain "gcli repo branches"
7
9
  And the output should contain "gcli repo contribs"
8
10
  And the output should contain "gcli repo create"
9
11
  And the output should contain "gcli repo edit"
12
+ And the output should contain "gcli repo delete"
10
13
  And the output should contain "gcli repo get"
11
14
  And the output should contain "gcli repo list"
12
- And the output should contain "gcli repo languages"
15
+ And the output should contain "gcli repo langs"
13
16
  And the output should contain "gcli repo tags"
14
17
  And the output should contain "gcli repo teams"
15
18
 
16
- Scenario: List repositories
19
+ Scenario: List all repositories
20
+ Given the GitHub API server:
21
+ """
22
+ get('/repositories') { status 200 }
23
+ """
24
+ When I run `gcli repo ls`
25
+ Then the exit status should be 0
26
+
27
+ Scenario: List repositories for user
17
28
  Given the GitHub API server:
18
29
  """
19
30
  get('/users/wycats/repos') { status 200 }
@@ -21,6 +32,22 @@ Feature: gcli repository
21
32
  When I run `gcli repo ls -u wycats`
22
33
  Then the exit status should be 0
23
34
 
35
+ Scenario: List repositories for organization
36
+ Given the GitHub API server:
37
+ """
38
+ get('/orgs/github/repos') { status 200 }
39
+ """
40
+ When I run `gcli repo ls -o github`
41
+ Then the exit status should be 0
42
+
43
+ Scenario: List repositories for organization
44
+ Given the GitHub API server:
45
+ """
46
+ get('/orgs/github/repos') { status 200 }
47
+ """
48
+ When I run `gcli repo ls -o github`
49
+ Then the exit status should be 0
50
+
24
51
  Scenario: Get repository
25
52
  Given the GitHub API server:
26
53
  """
@@ -87,11 +114,37 @@ Feature: gcli repository
87
114
  When I run `gcli repo create github`
88
115
  Then the exit status should be 0
89
116
 
117
+ Scenario: Create repository in organization
118
+ Given the GitHub API server:
119
+ """
120
+ post('/orgs/github/repos') { status 200 }
121
+ """
122
+ When I run `gcli repo create github/thor`
123
+ Then the exit status should be 0
124
+
90
125
  Scenario: Edit repository
91
126
  Given the GitHub API server:
92
127
  """
93
128
  patch('/repos/wycats/thor') { status 200 }
94
129
  """
95
- When I run `gcli repo edit wycats thor --params=name:thor`
130
+ When I run `gcli repo edit wycats thor new`
131
+ Then the exit status should be 0
132
+
133
+ Scenario: Delete repository
134
+ Given the GitHub API server:
135
+ """
136
+ delete('/repos/wycats/thor') { status 200 }
137
+ """
138
+ When I run `gcli repo del wycats thor`
139
+ Then the exit status should be 0
140
+
141
+ Scenario: Get repository branch
142
+ Given the GitHub API server:
143
+ """
144
+ get('/repos/wycats/thor/branches/master') {
145
+ status 200
146
+ }
147
+ """
148
+ When I run `gcli repo branch wycats thor master`
96
149
  Then the exit status should be 0
97
150
 
@@ -3,7 +3,7 @@
3
3
  module GithubCLI
4
4
 
5
5
  # The API class is the main entry point for creating GithubCLI APIs.
6
- class API
6
+ class API < Thor
7
7
 
8
8
  @@api = nil
9
9
 
@@ -17,6 +17,10 @@ module GithubCLI
17
17
  end
18
18
  end
19
19
 
20
+ # see http://stackoverflow.com/questions/5729071/how-to-compose-thor-tasks-in-separate-classes-modules-files
21
+
22
+ # this could become a command such as configure that gets class options
23
+
20
24
  def configure_api
21
25
  @@api = Github.new
22
26
  config = GithubCLI.config.data
@@ -36,8 +40,12 @@ module GithubCLI
36
40
 
37
41
  def output(format=:table, &block)
38
42
  response = block.call
39
- formatter = Formatter.new response, :format => format
40
- formatter.render_output
43
+ if response.respond_to?(:body)
44
+ formatter = Formatter.new response, :format => format
45
+ formatter.render_output
46
+ else
47
+ response
48
+ end
41
49
  end
42
50
 
43
51
  end
@@ -29,12 +29,24 @@ module GithubCLI
29
29
  end
30
30
  end
31
31
 
32
+ def delete(user, repo, params, format)
33
+ output format do
34
+ github_api.repos.delete user, repo, params
35
+ end
36
+ end
37
+
32
38
  def branches(user, repo, params, format)
33
39
  output format do
34
40
  github_api.repos.branches user, repo, params
35
41
  end
36
42
  end
37
43
 
44
+ def branch(user, repo, name, params, format)
45
+ output format do
46
+ github_api.repos.branch user, repo, name, params
47
+ end
48
+ end
49
+
38
50
  def contributors(user, repo, params, format)
39
51
  output format do
40
52
  github_api.repos.contributors user, repo, params
@@ -5,6 +5,12 @@ module GithubCLI
5
5
 
6
6
  class << self
7
7
 
8
+ def all(params, format)
9
+ output format do
10
+ github_api.users.all params
11
+ end
12
+ end
13
+
8
14
  def get(user, params, format)
9
15
  output format do
10
16
  github_api.users.get params.update(:user => user)
@@ -30,6 +30,8 @@ module GithubCLI
30
30
  class_option :token, :type => :string,
31
31
  :desc => 'Authentication token.',
32
32
  :banner => '<oauth token>'
33
+ class_option :login, :type => :string
34
+ class_option :password, :type => :string
33
35
  class_option "no-color", :type => :boolean,
34
36
  :desc => "Disable colorization in output."
35
37
  class_option "no-pager", :type => :boolean,
@@ -6,20 +6,19 @@ module GithubCLI
6
6
  namespace :gist
7
7
 
8
8
  desc 'list', 'List all gists'
9
- method_option :user, :type => :string, :aliases => ["-u"],
10
- :desc => 'List a <user> gists',
11
- :banner => '<user>'
12
- method_option :starred, :type => :boolean, :aliases => ["-s"],
13
- :default => false,
14
- :desc => 'List the authenticated users starred gists'
9
+ option :user, :type => :string, :aliases => ["-u"], :banner => '<user>',
10
+ :desc => 'List a <user> gists'
11
+ option :starred, :type => :boolean, :aliases => ["-s"], :default => false,
12
+ :desc => 'List the authenticated users starred gists'
13
+ option :since, :type => :string, :banner => "timestamp",
14
+ :desc => "a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ "
15
15
  def list
16
16
  if options[:starred]
17
17
  Gist.starred options[:params], options[:format]
18
18
  else
19
- if options[:user]
20
- options[:params]['user'] = options[:user]
21
- end
22
- Gist.all options[:params], options[:format]
19
+ params = options[:params].dup
20
+ params['user'] = options[:user] if options[:user]
21
+ Gist.all params, options[:format]
23
22
  end
24
23
  end
25
24
 
@@ -28,6 +27,10 @@ module GithubCLI
28
27
  Gist.get id, options[:params], options[:format]
29
28
  end
30
29
 
30
+ option :public, :type => :boolean, :default => false
31
+ option :desc, :type => :string
32
+ option :files, :type => :hash, :banner => "file1.txt:",
33
+ :desc => "Files that make up this gist. The key of which should be a required string filename and the value another required hash with parameters"
31
34
  desc 'create', 'Create a gist'
32
35
  long_desc <<-DESC
33
36
  Create a gist
@@ -40,9 +43,16 @@ module GithubCLI
40
43
  content - Required string - File contents.
41
44
  DESC
42
45
  def create
43
- Gist.create options[:params], options[:format]
46
+ params = options[:params].dup
47
+ params['description'] = options[:desc] if options[:desc]
48
+ params['public'] = options[:public] || false
49
+ params['files'] = options[:files] if options[:files]
50
+ Gist.create params, options[:format]
44
51
  end
45
52
 
53
+ option :desc, :type => :string
54
+ option :files, :type => :hash, :banner => "file1.txt:",
55
+ :desc => "Files that make up this gist. The key of which should be a required string filename and the value another required hash with parameters"
46
56
  desc 'edit <id>', 'Edit a gist'
47
57
  long_desc <<-DESC
48
58
  Edit a gist
@@ -55,7 +65,10 @@ module GithubCLI
55
65
  filename - Optional string - New name for this file.\n
56
66
  DESC
57
67
  def edit(id)
58
- Gist.edit id, options[:params], options[:format]
68
+ params = options[:params].dup
69
+ params['description'] = options[:desc] if options[:desc]
70
+ params['files'] = options[:files] if options[:files]
71
+ Gist.edit id, params, options[:format]
59
72
  end
60
73
 
61
74
  desc 'star <id>', 'Star a gist'
@@ -16,13 +16,35 @@ module GithubCLI
16
16
  end
17
17
 
18
18
  desc 'create <user> <repo>', 'Create a new Pull Request'
19
+ option :title, :type => :string
20
+ option :body, :type => :string
21
+ option :base, :type => :string,
22
+ :desc => "The branch you want your changes pulled into."
23
+ option :head, :type => :string,
24
+ :desc => "The branch where your changes are implemented"
25
+ option :issue, :type => :string,
26
+ :desc => "Issue number in this repository to turn into a Pull Request"
19
27
  def create(user, repo)
20
- PullRequest.create user, repo, options[:params], options[:format]
28
+ params = options[:params].dup
29
+ params['title'] = options[:title] if options[:title]
30
+ params['body'] = options[:body] if options[:body]
31
+ params['base'] = options[:base] if options[:base]
32
+ params['head'] = options[:head] if options[:head]
33
+ params['issue'] = options[:issue] if options[:issue]
34
+ PullRequest.create user, repo, params, options[:format]
21
35
  end
22
36
 
23
37
  desc 'update <user> <repo> <number>', 'Update a Pull Request'
38
+ option :title, :type => :string
39
+ option :body, :type => :string
40
+ option :state, :type => :string,
41
+ :desc => "State of this Pull Request. Valid values are open and closed"
24
42
  def update(user, repo, number)
25
- PullRequest.update user, repo, number, options[:params], options[:format]
43
+ params = options[:params].dup
44
+ params['title'] = options[:title] if options[:title]
45
+ params['body'] = options[:body] if options[:body]
46
+ params['state'] = options[:state] if options[:state]
47
+ PullRequest.update user, repo, number, params, options[:format]
26
48
  end
27
49
 
28
50
  desc 'commits <user> <repo> <number>', 'List commits on a Pull Request'
@@ -4,22 +4,29 @@ module GithubCLI
4
4
  class Commands::Repositories < Command
5
5
 
6
6
  namespace :repo
7
- # TODO: format_type options[:format]
8
7
 
8
+ option :org, :type => :string, :aliases => ["-o"], :banner => '<organization>',
9
+ :desc => 'List repositories for <organization>'
10
+ option :user, :type => :string, :aliases => ["-u"], :banner => '<user>',
11
+ :desc => 'List repositories for <user>'
12
+ option :since, :type => :string, :banner => '<id>',
13
+ :desc => "the integer ID of the last Repository that you've seen"
14
+ option :type, :type => :string,
15
+ :desc => "all, owner, public, private, member. Default: all."
16
+ option :sort, :type => :string,
17
+ :desc => "created, updated, pushed, full_name, default: full_name."
18
+ option :direction, :type => :string,
19
+ :desc => "asc or desc, default: when using full_name: asc, otherwise desc."
9
20
  desc 'list', 'Lists all repositories for the authenticated user'
10
- method_option :org, :type => :string, :aliases => ["-o"],
11
- :desc => 'List repositories for <organization>',
12
- :banner => '<organization>'
13
- method_option :user, :type => :string, :aliases => ["-u"],
14
- :desc => 'List repositories for <user>',
15
- :banner => '<user>'
16
21
  def list
17
- if options[:org]
18
- options[:params]['org'] = options[:org]
19
- elsif options[:user]
20
- options[:params]['user'] = options[:user]
21
- end
22
- Repository.all options[:params], options[:format]
22
+ params = options[:params].dup
23
+ params['org'] = options[:org] if options[:org]
24
+ params['user'] = options[:user] if options[:user]
25
+ params['since'] = options[:since] if options[:since]
26
+ params['type'] = options[:type] if options[:type]
27
+ params['sort'] = options[:sort] if options[:sort]
28
+ params['direction'] = options[:direction] if options[:direction]
29
+ Repository.all params, options[:format]
23
30
  end
24
31
 
25
32
  desc 'get <user> <repo>', 'Get a repository'
@@ -27,6 +34,25 @@ module GithubCLI
27
34
  Repository.get user, repo, options[:params], options[:format]
28
35
  end
29
36
 
37
+ option :org, :type => :string, :aliases => ["-o"],
38
+ :desc => 'Create repository in <organization>',
39
+ :banner => '<organization>'
40
+ option :desc, :type => :string, :banner => "description"
41
+ option :home, :type => :string, :banner => "homepage"
42
+ option :private, :type => :boolean,
43
+ :desc => "true to create a private repository, false to create a public one"
44
+ option :issues, :type => :boolean, :banner => "has_issues",
45
+ :desc => "true to enable issues for this repository, false to disable them"
46
+ option :wiki, :type => :boolean, :banner => "has_wiki",
47
+ :desc => "true to enable the wiki for this repository, false to disable it. Default is true"
48
+ option :downloads, :type => :boolean, :banner => "has_downloads",
49
+ :desc => "true to enable downloads for this repository "
50
+ option :team, :type => :string, :banner => "team <id>",
51
+ :desc => "The id of the team that will be granted access to this repository. This is only valid when creating a repo in an organization"
52
+ option :auto, :type => :string, :banner => "auto_init",
53
+ :desc => "true to create an initial commit with empty README. Default is false."
54
+ option :gitignore, :type => :string, :banner => "gitignore_template",
55
+ :desc => "Desired language or platform .gitignore template to apply."
30
56
  desc 'create [<org>/]<name>', 'Create a new repository <name> for the authenticated user.'
31
57
  long_desc <<-DESC
32
58
  Create a new repository for the autheticated user.
@@ -41,19 +67,40 @@ module GithubCLI
41
67
  has_downloads Optional boolean - true to enable downloads for this repository \n
42
68
  org Optional string - The organisation in which this repository will be created \n
43
69
  team_id - Optional number - The id of the team that will be granted access to this repository. This is only valid when creating a repo in an organization \n
70
+ auto_init - Optional boolean - true to create an initial commit with empty README. Default is false.
71
+ gitignore_template - Optional string - Desired language or platform .gitignore template to apply. Use the name of the template without the extension. For example, “Haskell” Ignored if auto_init parameter is not provided.
44
72
  DESC
45
- method_option :org, :type => :string, :aliases => ["-o"],
46
- :desc => 'Create repository in <organization>',
47
- :banner => '<organization>'
48
73
  def create(args)
49
- org, options[:params]['name'] = Arguments.new(args).parse
50
- options[:params]['org'] = org if org
51
- options[:params]['org'] = options[:org] if options[:org]
52
-
53
- Repository.create options[:params], options[:format]
74
+ params = options[:params].dup
75
+ org, params['name'] = Arguments.new(args).parse
76
+ params['org'] = org if org
77
+ params['org'] = options[:org] if options[:org]
78
+ params['description'] = options[:desc] if options[:desc]
79
+ params['homepage'] = options[:home] if options[:home]
80
+ params['private'] = options[:private] if options[:private]
81
+ params['has_issues'] = options[:issues] if options[:issues]
82
+ params['has_wiki'] = options[:wiki] if options[:wiki]
83
+ params['has_downloads'] = options[:downloads] if options[:downloads]
84
+ params['team_id'] = options[:team] if options[:team]
85
+ params['auto_init'] = options[:auto] if options[:auto]
86
+ params['gitignore_template'] = options[:gitignore] if options[:gitignore]
87
+
88
+ Repository.create params, options[:format]
54
89
  end
55
90
 
56
- desc 'edit <user> <repo>', 'Edit <repo> for an <user>.'
91
+ option :desc, :type => :string, :banner => "description"
92
+ option :home, :type => :string, :banner => "homepage"
93
+ option :private, :type => :boolean,
94
+ :desc => "true to create a private repository, false to create a public one"
95
+ option :issues, :type => :boolean, :banner => "has_issues",
96
+ :desc => "true to enable issues for this repository, false to disable them"
97
+ option :wiki, :type => :boolean, :banner => "has_wiki",
98
+ :desc => "true to enable the wiki for this repository, false to disable it. Default is true"
99
+ option :downloads, :type => :boolean, :banner => "has_downloads",
100
+ :desc => "true to enable downloads for this repository "
101
+ option :branch, :type => :string, :banner => "default branch",
102
+ :desc => "Update the default branch for this repository."
103
+ desc 'edit <user> <repo> <name>', 'Edit <repo> with <name> for an <user>.'
57
104
  long_desc <<-DESC
58
105
  Create a new repository for the autheticated user.
59
106
 
@@ -65,10 +112,26 @@ module GithubCLI
65
112
  private - Optional boolean - true to create a private repository, false to create a public one \n
66
113
  has_issues - Optional boolean - true to enable issues for this repository, false to disable them \n
67
114
  has_wiki - Optional boolean - true to enable the wiki for this repository, false to disable it. Default is true \n
68
- has_downloads Optional boolean - true to enable downloads for this repository \n
115
+ has_downloads - Optional boolean - true to enable downloads for this repository \n
116
+ default_branch - Optional string - update the default branch for this repository \n
69
117
  DESC
70
- def edit(user, repo)
71
- Repository.edit user, repo, options[:params], options[:format]
118
+ def edit(user, repo, name)
119
+ params = options[:params].dup
120
+ params['name'] = name
121
+ params['description'] = options[:desc] if options[:desc]
122
+ params['homepage'] = options[:home] if options[:home]
123
+ params['private'] = options[:private] if options[:private]
124
+ params['has_issues'] = options[:issues] if options[:issues]
125
+ params['has_wiki'] = options[:wiki] if options[:wiki]
126
+ params['has_downloads'] = options[:downloads] if options[:downloads]
127
+ params['default_branch'] = options[:branch] if options[:branch]
128
+
129
+ Repository.edit user, repo, params, options[:format]
130
+ end
131
+
132
+ desc 'delete <user> <repo>', 'Delete a repository'
133
+ def delete(user, repo)
134
+ Repository.delete user, repo, options[:params], options[:format]
72
135
  end
73
136
 
74
137
  desc 'branches <user> <repo>', 'List branches'
@@ -76,13 +139,18 @@ module GithubCLI
76
139
  Repository.branches user, repo, options[:params], options[:format]
77
140
  end
78
141
 
142
+ desc 'branch <user> <repo> <name>', 'Get branch'
143
+ def branch(user, repo, name)
144
+ Repository.branch user, repo, name, options[:params], options[:format]
145
+ end
146
+
79
147
  desc 'contribs <user> <repo>', 'List contributors'
80
148
  def contribs(user, repo)
81
149
  Repository.contributors user, repo, options[:params], options[:format]
82
150
  end
83
151
 
84
- desc 'languages <user> <repo>', 'Listing all languages'
85
- def languages(user, repo)
152
+ desc 'langs <user> <repo>', 'Listing all languages'
153
+ def langs(user, repo)
86
154
  Repository.languages user, repo, options[:params], options[:format]
87
155
  end
88
156
 
@@ -5,17 +5,41 @@ module GithubCLI
5
5
 
6
6
  namespace :user
7
7
 
8
+ desc 'list', 'List all users'
9
+ option :since, :type => :string, :banner => "<user>",
10
+ :desc => "The integer ID of the last User that you’ve seen."
11
+ def list
12
+ params = options[:params].dup
13
+ params['since'] = options[:since] if options[:since]
14
+ User.all params, options[:format]
15
+ end
16
+
8
17
  desc 'get', 'Get the authenticated user'
9
- method_option :user, :type => :string, :aliases => ["-u"],
10
- :desc => 'Get a single unauthenticated <user>',
11
- :banner => '<user>'
18
+ option :user, :type => :string, :aliases => ["-u"],
19
+ :desc => 'Get a single unauthenticated <user>',
20
+ :banner => '<user>'
12
21
  def get
13
22
  User.get options[:user], options[:params], options[:format]
14
23
  end
15
24
 
16
25
  desc 'update', 'Update the authenticated user'
26
+ option :name, :type => :string
27
+ option :email, :type => :string
28
+ option :blog, :type => :string
29
+ option :company, :type => :string
30
+ option :location, :type => :string
31
+ option :hireable, :type => :string
32
+ option :bio, :type => :string
17
33
  def update
18
- User.update options[:params], options[:format]
34
+ params = options[:params].dup
35
+ params['name'] = options[:name] if options[:name]
36
+ params['email'] = options[:email] if options[:email]
37
+ params['blog'] = options[:blog] if options[:blog]
38
+ params['company'] = options[:company] if options[:company]
39
+ params['location'] = options[:location] if options[:location]
40
+ params['hireable'] = options[:hireable] if options[:hireable]
41
+ params['bio'] = options[:bio] if options[:bio]
42
+ User.update params, options[:format]
19
43
  end
20
44
 
21
45
  end # Users
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module GithubCLI
4
- VERSION = "0.5.4"
4
+ VERSION = "0.5.5"
5
5
  end
@@ -0,0 +1,43 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe GithubCLI::Commands::Authorizations do
6
+ let(:format) { 'table' }
7
+ let(:id) { 1 }
8
+ let(:api_class) { GithubCLI::Authorization }
9
+
10
+ it "invokes auth:list" do
11
+ api_class.should_receive(:all).with({}, format)
12
+ subject.invoke "auth:list", []
13
+ end
14
+
15
+ it "invokes auth:get" do
16
+ api_class.should_receive(:get).with(id, {}, format)
17
+ subject.invoke "auth:get", [id]
18
+ end
19
+
20
+ it "invokes auth:create --scopes --note --note_url" do
21
+ api_class.should_receive(:create).with({"scopes" => ["repo"],
22
+ "note" => "github_cli",
23
+ "note_url" => "https://github.com/peter-murach/github_cli"}, format)
24
+ subject.invoke "auth:create", [], :scopes => ["repo"], :note => 'github_cli', :note_url => "https://github.com/peter-murach/github_cli"
25
+ end
26
+
27
+ it "invokes auth:update" do
28
+ api_class.should_receive(:update).with(id, {}, format)
29
+ subject.invoke "auth:update", [id]
30
+ end
31
+
32
+ it "invokes auth:update --scopes --note --note_url" do
33
+ api_class.should_receive(:update).with(id, {"scopes" => ["repo"],
34
+ "note" => "github_cli",
35
+ "note_url" => "https://github.com/peter-murach/github_cli"}, format)
36
+ subject.invoke "auth:update", [id], :scopes => ["repo"], :note => 'github_cli', :note_url => "https://github.com/peter-murach/github_cli"
37
+ end
38
+
39
+ it "invokes auth:delete" do
40
+ api_class.should_receive(:delete).with(id, {}, format)
41
+ subject.invoke "auth:delete", [id]
42
+ end
43
+ end
@@ -0,0 +1,76 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe GithubCLI::Commands::Gists do
6
+ let(:format) { 'table' }
7
+ let(:user) { 'peter-murach' }
8
+ let(:id) { 1 }
9
+ let(:api_class) { GithubCLI::Gist }
10
+
11
+ it "invokes gist:list" do
12
+ api_class.should_receive(:all).with({}, format)
13
+ subject.invoke "gist:list", []
14
+ end
15
+
16
+ it "invokes gist:list --user" do
17
+ api_class.should_receive(:all).with({"user" => user}, format)
18
+ subject.invoke "gist:list", [], :user => user
19
+ end
20
+
21
+ it "invokes gist:list --starred" do
22
+ api_class.should_receive(:starred).with({}, format)
23
+ subject.invoke "gist:list", [], :starred => true
24
+ end
25
+
26
+ it "invokes gist:get" do
27
+ api_class.should_receive(:get).with(id, {}, format)
28
+ subject.invoke "gist:get", [id]
29
+ end
30
+
31
+ it "invokes gist:create" do
32
+ api_class.should_receive(:create).with({'public' => false}, format)
33
+ subject.invoke "gist:create", []
34
+ end
35
+
36
+ it "invokes gist:create --public --desc" do
37
+ api_class.should_receive(:create).with({'public' => true,
38
+ 'description' => 'new'}, format)
39
+ subject.invoke "gist:create", [], :desc => 'new', :public => true
40
+ end
41
+
42
+ it "invokes gist:edit id" do
43
+ api_class.should_receive(:edit).with(id, {}, format)
44
+ subject.invoke "gist:edit", [id]
45
+ end
46
+
47
+ it "invokes gist:edit id --desc" do
48
+ api_class.should_receive(:edit).with(id, {'description' => 'new'}, format)
49
+ subject.invoke "gist:edit", [id], :desc => 'new'
50
+ end
51
+
52
+ it "invokes gist:star id" do
53
+ api_class.should_receive(:star).with(id, {}, format)
54
+ subject.invoke "gist:star", [id]
55
+ end
56
+
57
+ it "invokes gist:unstar id" do
58
+ api_class.should_receive(:unstar).with(id, {}, format)
59
+ subject.invoke "gist:unstar", [id]
60
+ end
61
+
62
+ it "invokes gist:starred id" do
63
+ api_class.should_receive(:starred?).with(id, {}, format)
64
+ subject.invoke "gist:starred", [id]
65
+ end
66
+
67
+ it "invokes gist:fork id" do
68
+ api_class.should_receive(:fork).with(id, {}, format)
69
+ subject.invoke "gist:fork", [id]
70
+ end
71
+
72
+ it "invokes gist:delete id" do
73
+ api_class.should_receive(:delete).with(id, {}, format)
74
+ subject.invoke "gist:delete", [id]
75
+ end
76
+ end
@@ -0,0 +1,57 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe GithubCLI::Commands::PullRequests do
6
+ let(:format) { 'table' }
7
+ let(:user) { 'peter-murach' }
8
+ let(:repo) { 'github_cli' }
9
+ let(:number) { 1 }
10
+ let(:api_class) { GithubCLI::PullRequest }
11
+
12
+ it "invokes pull:list" do
13
+ api_class.should_receive(:list).with(user, repo, {}, format)
14
+ subject.invoke "pull:list", [user, repo]
15
+ end
16
+
17
+ it "invokes pull:get" do
18
+ api_class.should_receive(:get).with(user, repo, number, {}, format)
19
+ subject.invoke "pull:get", [user, repo, number]
20
+ end
21
+
22
+ it "invokes pull:create --title" do
23
+ api_class.should_receive(:create).with(user, repo, {"title" => 'new'}, format)
24
+ subject.invoke "pull:create", [user, repo], :title => 'new'
25
+ end
26
+
27
+ it "invokes pull:update" do
28
+ api_class.should_receive(:update).with(user, repo, number, {}, format)
29
+ subject.invoke "pull:update", [user, repo, number]
30
+ end
31
+
32
+ it "invokes pull:update --title" do
33
+ api_class.should_receive(:update).with(user, repo, number,
34
+ {'title' => 'new'}, format)
35
+ subject.invoke "pull:update", [user, repo, number], :title => 'new'
36
+ end
37
+
38
+ it "invokes pull:commits" do
39
+ api_class.should_receive(:commits).with(user, repo, number, {}, format)
40
+ subject.invoke "pull:commits", [user, repo, number]
41
+ end
42
+
43
+ it "invokes pull:files" do
44
+ api_class.should_receive(:files).with(user, repo, number, {}, format)
45
+ subject.invoke "pull:files", [user, repo, number]
46
+ end
47
+
48
+ it "invokes pull:merged" do
49
+ api_class.should_receive(:merged).with(user, repo, number, {}, format)
50
+ subject.invoke "pull:merged", [user, repo, number]
51
+ end
52
+
53
+ it "invokes pull:merge" do
54
+ api_class.should_receive(:merge).with(user, repo, number, {}, format)
55
+ subject.invoke "pull:merge", [user, repo, number]
56
+ end
57
+ end
@@ -0,0 +1,107 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe GithubCLI::Commands::Repositories do
6
+ let(:format) { 'table' }
7
+ let(:user) { 'peter-murach' }
8
+ let(:repo) { 'github_cli' }
9
+ let(:org) { 'rails' }
10
+ let(:api_class) { GithubCLI::Repository }
11
+
12
+ it "invokes repo:list" do
13
+ api_class.should_receive(:all).with({}, format)
14
+ subject.invoke "repo:list", []
15
+ end
16
+
17
+ it "invokes repo:list --org" do
18
+ api_class.should_receive(:all).with({"org" => org}, format)
19
+ subject.invoke "repo:list", [], :org => org
20
+ end
21
+
22
+ it "invokes repo:list --user" do
23
+ api_class.should_receive(:all).with({"user" => user}, format)
24
+ subject.invoke "repo:list", [], :user => user
25
+ end
26
+
27
+ it "invokes repo:list --user --type --sort --direction" do
28
+ api_class.should_receive(:all).with({"user" => user, "type" => "owner",
29
+ "sort" => "created", "direction" => "asc"}, format)
30
+ subject.invoke "repo:list", [], :user => user, :type => "owner",
31
+ :sort => "created", :direction => "asc"
32
+ end
33
+
34
+ it "invokes repo:get" do
35
+ api_class.should_receive(:get).with(user, repo, {}, format)
36
+ subject.invoke "repo:get", [user, repo]
37
+ end
38
+
39
+ it "invokes repo:create name" do
40
+ api_class.should_receive(:create).with({'name' => repo}, format)
41
+ subject.invoke "repo:create", [repo]
42
+ end
43
+
44
+ it "invokes repo:create org/name" do
45
+ api_class.should_receive(:create).with({'name' => repo, 'org' => org}, format)
46
+ subject.invoke "repo:create", ["#{org}/#{repo}"]
47
+ end
48
+
49
+ it "invokes repo:create name --org" do
50
+ api_class.should_receive(:create).with({'name' => repo, 'org' => org}, format)
51
+ subject.invoke "repo:create", [repo], :org => org
52
+ end
53
+
54
+ it "invokes repo:create name --wiki --issues --downloads --auto_init" do
55
+ api_class.should_receive(:create).with({'name' => repo, "has_wiki" => true,
56
+ "has_issues" => true, "has_downloads" => true, "auto_init" => true}, format)
57
+ subject.invoke "repo:create", [repo], :wiki => true, :issues => true,
58
+ :downloads => true, :auto => true
59
+ end
60
+
61
+ it "invokes repo:edit user repo name" do
62
+ api_class.should_receive(:edit).with(user, repo, {'name' => 'new'}, format)
63
+ subject.invoke "repo:edit", [user, repo, 'new']
64
+ end
65
+
66
+ it "invokes repo:edit user repo name --wiki --issues --downloads --auto_init" do
67
+ api_class.should_receive(:edit).with(user, repo, {'name' => 'new',
68
+ "has_wiki" => true, "has_issues" => true, "has_downloads" => true}, format)
69
+ subject.invoke "repo:edit", [user, repo, 'new'], :wiki => true,
70
+ :issues => true, :downloads => true
71
+ end
72
+
73
+ it "invokes repo:delete user repo" do
74
+ api_class.should_receive(:delete).with(user, repo, {}, format)
75
+ subject.invoke "repo:delete", [user, repo]
76
+ end
77
+
78
+ it "invokes repo:branches" do
79
+ api_class.should_receive(:branches).with(user, repo, {}, format)
80
+ subject.invoke "repo:branches", [user, repo]
81
+ end
82
+
83
+ it "invokes repo:branch" do
84
+ api_class.should_receive(:branch).with(user, repo, 'new', {}, format)
85
+ subject.invoke "repo:branch", [user, repo, 'new']
86
+ end
87
+
88
+ it "invokes repo:contribs" do
89
+ api_class.should_receive(:contributors).with(user, repo, {}, format)
90
+ subject.invoke "repo:contribs", [user, repo]
91
+ end
92
+
93
+ it "invokes repo:langs" do
94
+ api_class.should_receive(:languages).with(user, repo, {}, format)
95
+ subject.invoke "repo:langs", [user, repo]
96
+ end
97
+
98
+ it "invokes repo:tags" do
99
+ api_class.should_receive(:tags).with(user, repo, {}, format)
100
+ subject.invoke "repo:tags", [user, repo]
101
+ end
102
+
103
+ it "invokes repo:teams" do
104
+ api_class.should_receive(:teams).with(user, repo, {}, format)
105
+ subject.invoke "repo:teams", [user, repo]
106
+ end
107
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-23 00:00:00.000000000Z
12
+ date: 2013-03-30 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: github_api
16
- requirement: &2153408740 !ruby/object:Gem::Requirement
16
+ requirement: &2156305200 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0.9'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2153408740
24
+ version_requirements: *2156305200
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &2153408300 !ruby/object:Gem::Requirement
27
+ requirement: &2156304760 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2153408300
35
+ version_requirements: *2156304760
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: aruba
38
- requirement: &2153407820 !ruby/object:Gem::Requirement
38
+ requirement: &2156304140 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2153407820
46
+ version_requirements: *2156304140
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
- requirement: &2153407400 !ruby/object:Gem::Requirement
49
+ requirement: &2156303440 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2153407400
57
+ version_requirements: *2156303440
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: communist
60
- requirement: &2153406960 !ruby/object:Gem::Requirement
60
+ requirement: &2156302700 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2153406960
68
+ version_requirements: *2156302700
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: ronn
71
- requirement: &2153406500 !ruby/object:Gem::Requirement
71
+ requirement: &2156301940 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2153406500
79
+ version_requirements: *2156301940
80
80
  description: CLI-based access to GitHub API v3
81
81
  email:
82
82
  - ''
@@ -265,16 +265,20 @@ files:
265
265
  - spec/github_cli/cli_spec.rb
266
266
  - spec/github_cli/command_spec.rb
267
267
  - spec/github_cli/commands/assignees_spec.rb
268
+ - spec/github_cli/commands/authorizations_spec.rb
268
269
  - spec/github_cli/commands/blobs_spec.rb
269
270
  - spec/github_cli/commands/collaborators_spec.rb
270
271
  - spec/github_cli/commands/commits_spec.rb
271
272
  - spec/github_cli/commands/emails_spec.rb
272
273
  - spec/github_cli/commands/events_spec.rb
273
274
  - spec/github_cli/commands/followers_spec.rb
275
+ - spec/github_cli/commands/gists_spec.rb
274
276
  - spec/github_cli/commands/keys_spec.rb
275
277
  - spec/github_cli/commands/labels_spec.rb
276
278
  - spec/github_cli/commands/milestones_spec.rb
279
+ - spec/github_cli/commands/pull_requests_spec.rb
277
280
  - spec/github_cli/commands/references_spec.rb
281
+ - spec/github_cli/commands/repositories_spec.rb
278
282
  - spec/github_cli/commands/starring_spec.rb
279
283
  - spec/github_cli/commands/tags_spec.rb
280
284
  - spec/github_cli/commands/trees_spec.rb
@@ -361,16 +365,20 @@ test_files:
361
365
  - spec/github_cli/cli_spec.rb
362
366
  - spec/github_cli/command_spec.rb
363
367
  - spec/github_cli/commands/assignees_spec.rb
368
+ - spec/github_cli/commands/authorizations_spec.rb
364
369
  - spec/github_cli/commands/blobs_spec.rb
365
370
  - spec/github_cli/commands/collaborators_spec.rb
366
371
  - spec/github_cli/commands/commits_spec.rb
367
372
  - spec/github_cli/commands/emails_spec.rb
368
373
  - spec/github_cli/commands/events_spec.rb
369
374
  - spec/github_cli/commands/followers_spec.rb
375
+ - spec/github_cli/commands/gists_spec.rb
370
376
  - spec/github_cli/commands/keys_spec.rb
371
377
  - spec/github_cli/commands/labels_spec.rb
372
378
  - spec/github_cli/commands/milestones_spec.rb
379
+ - spec/github_cli/commands/pull_requests_spec.rb
373
380
  - spec/github_cli/commands/references_spec.rb
381
+ - spec/github_cli/commands/repositories_spec.rb
374
382
  - spec/github_cli/commands/starring_spec.rb
375
383
  - spec/github_cli/commands/tags_spec.rb
376
384
  - spec/github_cli/commands/trees_spec.rb