github_cli 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/.rvmrc +1 -1
  2. data/.travis.yml +0 -1
  3. data/Gemfile.lock +7 -5
  4. data/README.md +25 -2
  5. data/features/executable.feature +11 -9
  6. data/fixtures/.githubrc +9 -0
  7. data/fixtures/simple_config +1 -0
  8. data/github_cli.gemspec +1 -1
  9. data/lib/github_cli/api.rb +6 -0
  10. data/lib/github_cli/apis.rb +4 -0
  11. data/lib/github_cli/apis/blob.rb +2 -2
  12. data/lib/github_cli/apis/commit.rb +2 -2
  13. data/lib/github_cli/apis/download.rb +30 -0
  14. data/lib/github_cli/apis/fork.rb +2 -2
  15. data/lib/github_cli/apis/hook.rb +34 -0
  16. data/lib/github_cli/apis/key.rb +30 -0
  17. data/lib/github_cli/apis/label.rb +1 -1
  18. data/lib/github_cli/apis/reference.rb +7 -7
  19. data/lib/github_cli/apis/repository.rb +6 -6
  20. data/lib/github_cli/apis/tag.rb +2 -2
  21. data/lib/github_cli/apis/tree.rb +2 -2
  22. data/lib/github_cli/apis/watching.rb +30 -0
  23. data/lib/github_cli/cli.rb +2 -31
  24. data/lib/github_cli/command.rb +7 -1
  25. data/lib/github_cli/commands.rb +4 -0
  26. data/lib/github_cli/commands/blobs.rb +6 -0
  27. data/lib/github_cli/commands/commits.rb +18 -0
  28. data/lib/github_cli/commands/downloads.rb +67 -0
  29. data/lib/github_cli/commands/forks.rb +4 -2
  30. data/lib/github_cli/commands/hooks.rb +67 -0
  31. data/lib/github_cli/commands/keys.rb +56 -0
  32. data/lib/github_cli/commands/references.rb +19 -7
  33. data/lib/github_cli/commands/repositories.rb +29 -1
  34. data/lib/github_cli/commands/tags.rb +17 -0
  35. data/lib/github_cli/commands/trees.rb +16 -0
  36. data/lib/github_cli/commands/watching.rb +49 -0
  37. data/lib/github_cli/config.rb +1 -1
  38. data/lib/github_cli/subcommands.rb +49 -0
  39. data/lib/github_cli/version.rb +1 -1
  40. data/spec/github_cli/config_spec.rb +7 -1
  41. data/spec/spec_helper.rb +1 -1
  42. metadata +23 -13
data/.rvmrc CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
- environment_id="ruby-1.9.3-p0@github_cli"
3
+ environment_id="ruby-1.9.2-p290@github_cli"
4
4
 
5
5
  #
6
6
  # First we attempt to load the desired environment directly from the environment
@@ -5,6 +5,5 @@ branches:
5
5
  notifications:
6
6
  email:false
7
7
  rvm:
8
- - 1.8.7
9
8
  - 1.9.2
10
9
  - 1.9.3
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- github_cli (0.1.3)
5
- github_api (~> 0.4.8)
4
+ github_cli (0.2.0)
5
+ github_api (~> 0.5.0)
6
6
  thor
7
7
 
8
8
  GEM
@@ -31,15 +31,17 @@ GEM
31
31
  ffi (1.0.11)
32
32
  gherkin (2.9.0)
33
33
  json (>= 1.4.6)
34
- github_api (0.4.8)
34
+ github_api (0.5.0)
35
35
  faraday (~> 0.7.6)
36
36
  hashie (~> 1.2.0)
37
- multi_json (~> 1.1.0)
37
+ multi_json (~> 1.3)
38
+ nokogiri (~> 1.5.2)
38
39
  oauth2 (~> 0.5.2)
39
40
  hashie (1.2.0)
40
41
  json (1.6.5)
41
- multi_json (1.1.0)
42
+ multi_json (1.3.2)
42
43
  multipart-post (1.1.5)
44
+ nokogiri (1.5.2)
43
45
  oauth2 (0.5.2)
44
46
  faraday (~> 0.7)
45
47
  multi_json (~> 1.0)
data/README.md CHANGED
@@ -39,7 +39,8 @@ $ ghc init
39
39
  ```
40
40
 
41
41
  This will setup a `.githubrc` configuration file in your home directory with
42
- all the global settings.
42
+ all the global settings. During the install process you will be prompted for your
43
+ `authentication token`.
43
44
 
44
45
  ### Getting a list of commands
45
46
 
@@ -49,6 +50,12 @@ You can list all GitHub APIs comamnds:
49
50
  $ ghc list
50
51
  ```
51
52
 
53
+ to limit returned results pass `pattern`
54
+
55
+ ```shell
56
+ $ ghc list re* # Returns all commands matching the pattern
57
+ ```
58
+
52
59
  ### API
53
60
 
54
61
  Interact with git data:
@@ -74,7 +81,23 @@ Interact with repositories:
74
81
  $ ghc repo
75
82
  $ ghc download
76
83
  $ ghc fork
77
- $ ghc keys
84
+ $ ghc hook
85
+ $ ghc key
86
+ $ ghc watching
87
+ ```
88
+
89
+ ### Examples
90
+
91
+ You can create repository by supplying required parameters
92
+
93
+ ```shell
94
+ ghc repo create --params=name:'octocat' description:'Test repo for kitty.'
95
+ ```
96
+
97
+ To find out which options are required type
98
+
99
+ ```shell
100
+ ghc repo help create
78
101
  ```
79
102
 
80
103
  ## Contributing
@@ -23,12 +23,14 @@ Feature: The GHC Executable
23
23
  And the output should contain "ghc <command>"
24
24
 
25
25
  Examples:
26
- | command |
27
- | repo |
28
- | issue |
29
- | blob |
30
- | tree |
31
- | ref |
32
- | pull |
33
- | fork |
34
- | commit |
26
+ | command |
27
+ | repo |
28
+ | issue |
29
+ | blob |
30
+ | tree |
31
+ | ref |
32
+ | pull |
33
+ | fork |
34
+ | commit |
35
+ | download |
36
+ | key |
@@ -0,0 +1,9 @@
1
+ ---
2
+ oauth_token: ad7f9asdf97as98df7as9fd7
3
+ basic_auth: 'login:password'
4
+ host:
5
+ user:
6
+ repo:
7
+ commands:
8
+ issue-list: { inputs: 'ticket' }
9
+ issue-get: {}
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  oauth_token: ad7f9asdf97as98df7as9fd7
3
+ basic_auth: 'login:password'
3
4
  host:
4
5
  user:
5
6
  repo:
@@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = GithubCLI::VERSION
17
17
 
18
- gem.add_dependency 'github_api', '~> 0.4.8'
18
+ gem.add_dependency 'github_api', '~> 0.5.0'
19
19
  gem.add_dependency 'thor'
20
20
 
21
21
  gem.add_development_dependency 'rspec'
@@ -21,5 +21,11 @@ module GithubCLI
21
21
  def self.configure_api
22
22
  end
23
23
 
24
+ class All
25
+ def initialize
26
+ github_api
27
+ end
28
+ end
29
+
24
30
  end # API
25
31
  end # GithubCLI
@@ -11,12 +11,16 @@ end
11
11
  %w[
12
12
  blob
13
13
  commit
14
+ download
14
15
  fork
16
+ key
17
+ label
15
18
  pull_request
16
19
  reference
17
20
  repository
18
21
  tag
19
22
  tree
23
+ watching
20
24
  ].each do |api|
21
25
  require_api api
22
26
  end
@@ -6,11 +6,11 @@ module GithubCLI
6
6
  class << self
7
7
 
8
8
  def get(user, repo, sha, params)
9
- github_api.repos.get_blob user, repo, params
9
+ github_api.git_data.blobs.get user, repo, params
10
10
  end
11
11
 
12
12
  def create(user, repo, params)
13
- github_api.repos.create_blob user, repo, params
13
+ github_api.git_data.blobs.create user, repo, params
14
14
  end
15
15
  end
16
16
 
@@ -6,11 +6,11 @@ module GithubCLI
6
6
  class << self
7
7
 
8
8
  def get(user, repo, sha, params)
9
- github_api.git_data.commit user, repo, params
9
+ github_api.git_data.commits.get user, repo, params
10
10
  end
11
11
 
12
12
  def create(user, repo, params)
13
- github_api.repos.create_commit user, repo, params
13
+ github_api.git_data.commits.create user, repo, params
14
14
  end
15
15
  end
16
16
 
@@ -0,0 +1,30 @@
1
+ # encoding: utf-8
2
+
3
+ module GithubCLI
4
+ class Download < API
5
+
6
+ class << self
7
+
8
+ def all(user, repo, params)
9
+ github_api.repos.downloads.list user, repo, params
10
+ end
11
+
12
+ def get(user, repo, id, params)
13
+ github_api.repos.downloads.get user, repo, id, params
14
+ end
15
+
16
+ def create(user, repo, params)
17
+ github_api.repos.downloads.create user, repo, params
18
+ end
19
+
20
+ def upload(resource, filename)
21
+ github_api.repos.downloads.upload resource, filename
22
+ end
23
+
24
+ def delete(user, repo, id, params)
25
+ github_api.repos.downloads.delete user, repo, id, params
26
+ end
27
+ end
28
+
29
+ end # Download
30
+ end # GithubCLI
@@ -6,11 +6,11 @@ module GithubCLI
6
6
  class << self
7
7
 
8
8
  def all(user, repo, params)
9
- github_api.repos.forks user, repo, params
9
+ github_api.repos.forks.list user, repo, params
10
10
  end
11
11
 
12
12
  def create(user, repo, params)
13
- github_api.repos.create_fork user, repo, params
13
+ github_api.repos.forks.create user, repo, params
14
14
  end
15
15
  end
16
16
 
@@ -0,0 +1,34 @@
1
+ # encoding: utf-8
2
+
3
+ module GithubCLI
4
+ class Hook < API
5
+
6
+ class << self
7
+
8
+ def all(user, repo, params)
9
+ github_api.repos.hooks.list user, repo, params
10
+ end
11
+
12
+ def get(user, repo, id, params)
13
+ github_api.repos.hooks.get user, repo, id, params
14
+ end
15
+
16
+ def create(user, repo, params)
17
+ github_api.repos.hooks.create user, repo, params
18
+ end
19
+
20
+ def edit(user, repo, id, params)
21
+ github_api.repos.hooks.edit user, repo, id, params
22
+ end
23
+
24
+ def test(user, repo, id, params)
25
+ github_api.repos.hooks.test user, repo, id, params
26
+ end
27
+
28
+ def delete(user, repo, id, params)
29
+ github_api.repos.hooks.delete user, repo, id, params
30
+ end
31
+ end
32
+
33
+ end # Hook
34
+ end # GithubCLI
@@ -0,0 +1,30 @@
1
+ # encoding: utf-8
2
+
3
+ module GithubCLI
4
+ class Key < API
5
+
6
+ class << self
7
+
8
+ def all(user, repo, params)
9
+ github_api.repos.keys.list user, repo, params
10
+ end
11
+
12
+ def get(user, repo, id, params)
13
+ github_api.repos.keys.get user, repo, id, params
14
+ end
15
+
16
+ def create(user, repo, params)
17
+ github_api.repos.keys.create user, repo, params
18
+ end
19
+
20
+ def edit(user, repo, id, params)
21
+ github_api.repos.keys.edit user, repo, id, params
22
+ end
23
+
24
+ def delete(user, repo, id, params)
25
+ github_api.repos.keys.delete user, repo, id, params
26
+ end
27
+ end
28
+
29
+ end # Key
30
+ end # GithubCLI
@@ -34,7 +34,7 @@ module GithubCLI
34
34
  end
35
35
 
36
36
  def remove(user, repo, number, name=nil, params)
37
- github_api,issues.remove_label user, repo, number, name, params
37
+ github_api.issues.remove_label user, repo, number, name, params
38
38
  end
39
39
 
40
40
  def replace(user, repo, number, *args)
@@ -5,24 +5,24 @@ module GithubCLI
5
5
 
6
6
  class << self
7
7
 
8
- def get(user, repo, ref, params)
9
- github_api.git_data.reference user, repo, ref, params
8
+ def list(user, repo, ref, params)
9
+ github_api.git_data.references.list user, repo, ref, params
10
10
  end
11
11
 
12
- def list(user, repo, ref, params)
13
- github_api.git_data.references user, repo, ref, params
12
+ def get(user, repo, ref, params)
13
+ github_api.git_data.references.get user, repo, ref, params
14
14
  end
15
15
 
16
16
  def create(user, repo, params)
17
- github_api.git_data.create_reference user, repo, params
17
+ github_api.git_data.references.create user, repo, params
18
18
  end
19
19
 
20
20
  def update(user, repo, ref, params)
21
- github_api.git_data.update_reference user, repo, ref, params
21
+ github_api.git_data.references.update user, repo, ref, params
22
22
  end
23
23
 
24
24
  def delete(user, repo, ref, params)
25
- github_api.git_data.delete_reference user, repo, ref, params
25
+ github_api.git_data.references.delete user, repo, ref, params
26
26
  end
27
27
  end
28
28
 
@@ -6,19 +6,19 @@ module GithubCLI
6
6
  class << self
7
7
 
8
8
  def all(params)
9
- github_api.repos.repos(params)
9
+ github_api.repos.list params
10
10
  end
11
11
 
12
12
  def get(user, repo, params)
13
- github_api.repos.get_repo user, repo, params
13
+ github_api.repos.get user, repo, params
14
14
  end
15
15
 
16
- def create(user, repo, params)
17
- github_api.repos.create_repo user, repo, params
16
+ def create(params)
17
+ github_api.repos.create params
18
18
  end
19
19
 
20
- def edit
21
- github_api.repos.edit_repo user, repo, params
20
+ def edit(user, repo, params)
21
+ github_api.repos.edit user, repo, params
22
22
  end
23
23
 
24
24
  def branches(user, repo, params)
@@ -6,11 +6,11 @@ module GithubCLI
6
6
  class << self
7
7
 
8
8
  def get(user, repo, sha, params)
9
- github_api.repos.get_tag user, repo, params
9
+ github_api.git_data.tags.get user, repo, params
10
10
  end
11
11
 
12
12
  def create(user, repo, params)
13
- github_api.repos.create_tag user, repo, params
13
+ github_api.git_data.tags.create user, repo, params
14
14
  end
15
15
  end
16
16
 
@@ -6,11 +6,11 @@ module GithubCLI
6
6
  class << self
7
7
 
8
8
  def get(user, repo, sha, params)
9
- github_api.repos.get_tree user, repo, params
9
+ github_api.git_data.trees.get user, repo, sha, params
10
10
  end
11
11
 
12
12
  def create(user, repo, params)
13
- github_api.repos.create_tree user, repo, params
13
+ github_api.git_data.trees.create user, repo, params
14
14
  end
15
15
  end
16
16
 
@@ -0,0 +1,30 @@
1
+ # encoding: utf-8
2
+
3
+ module GithubCLI
4
+ class Watching < API
5
+
6
+ class << self
7
+
8
+ def watchers(user, repo, params)
9
+ github_api.repos.watching.watchers user, repo, params
10
+ end
11
+
12
+ def watched(params)
13
+ github_api.repos.watching.watched user, repo, id, params
14
+ end
15
+
16
+ def watching?(user, repo, params)
17
+ github_api.repos.watching.watching? user, repo, params
18
+ end
19
+
20
+ def start_watching(user, repo, params)
21
+ github_api.repos.watching.start_watching user, repo, params
22
+ end
23
+
24
+ def stop_watching(user, repo, params)
25
+ github_api.repos.watching.stop_watching user, repo, params
26
+ end
27
+ end
28
+
29
+ end # Watching
30
+ end # GithubCLI
@@ -1,8 +1,9 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module GithubCLI
4
- class CLI < ::Thor
4
+ class CLI < Thor
5
5
  include Thor::Actions
6
+ require 'github_cli/subcommands'
6
7
 
7
8
  def initialize(*args)
8
9
  super
@@ -63,36 +64,6 @@ module GithubCLI
63
64
  Terminal.print_commands pattern
64
65
  end
65
66
 
66
- desc "blob <command>", "Leverage Blobs API"
67
- subcommand "blob", GithubCLI::Commands::Blobs
68
-
69
- desc "commit <command>", "Leverage Commits API"
70
- subcommand "commit", GithubCLI::Commands::Commits
71
-
72
- desc "fork <command>", "Leverage Forks API"
73
- subcommand "fork", GithubCLI::Commands::Forks
74
-
75
- desc "issue <command>", "Leverage Issues API"
76
- subcommand "issue", GithubCLI::Commands::Issues
77
-
78
- desc "label <command>", "Leverage Labels API"
79
- subcommand "label", GithubCLI::Commands::Labels
80
-
81
- desc "pull <command>", "Leverage Pull Requests API"
82
- subcommand "pull", GithubCLI::Commands::PullRequests
83
-
84
- desc "ref <command>", "Leverage References API"
85
- subcommand "ref", GithubCLI::Commands::References
86
-
87
- desc "repo <command>", "Leverage Repositories API"
88
- subcommand "repo", GithubCLI::Commands::Repositories
89
-
90
- desc "tag <command>", "Leverage Tags API"
91
- subcommand "tag", GithubCLI::Commands::Tags
92
-
93
- desc "tree <command>", "Leverage Trees API"
94
- subcommand "tree", GithubCLI::Commands::Trees
95
-
96
67
  desc 'version', 'Display Github CLI version.'
97
68
  def version
98
69
  say "Github CLI #{GithubCLI::VERSION}"
@@ -3,7 +3,13 @@
3
3
  module GithubCLI
4
4
  class Command < Thor
5
5
 
6
- API_CLASSES = %w( c_l_i repo issue label tree blob reference pull commit fork )
6
+ API_CLASSES = %w(
7
+ c_l_i
8
+ repo download key fork
9
+ issue label
10
+ tag tree blob reference commit
11
+ pull
12
+ )
7
13
 
8
14
  HELP_COMMAND = 'help'
9
15
 
@@ -4,13 +4,17 @@ module GithubCLI
4
4
  module Commands
5
5
  autoload :Blobs, 'github_cli/commands/blobs'
6
6
  autoload :Commits, 'github_cli/commands/commits'
7
+ autoload :Downloads, 'github_cli/commands/downloads'
7
8
  autoload :Forks, 'github_cli/commands/forks'
9
+ autoload :Hooks, 'github_cli/commands/hooks'
8
10
  autoload :Issues, 'github_cli/commands/issues'
11
+ autoload :Keys, 'github_cli/commands/keys'
9
12
  autoload :Labels, 'github_cli/commands/labels'
10
13
  autoload :PullRequests, 'github_cli/commands/pull_requests'
11
14
  autoload :References, 'github_cli/commands/references'
12
15
  autoload :Repositories, 'github_cli/commands/repositories'
13
16
  autoload :Tags, 'github_cli/commands/tags'
14
17
  autoload :Trees, 'github_cli/commands/trees'
18
+ autoload :Watching, 'github_cli/commands/watching'
15
19
  end # Commands
16
20
  end # GithubCLI
@@ -13,6 +13,12 @@ module GithubCLI
13
13
  end
14
14
 
15
15
  desc 'create <user> <repo>', 'Create a new Blob'
16
+ long_desc <<-DESC
17
+ Inputs
18
+
19
+ content - String of content \n
20
+ encoding - String containing encoding utf-8 or base64
21
+ DESC
16
22
  method_option :params, :type => :hash, :default => {},
17
23
  :desc => 'Additonal request parameters e.i per_page:100'
18
24
  def create(user, repo)
@@ -13,6 +13,24 @@ module GithubCLI
13
13
  end
14
14
 
15
15
  desc 'create <user> <repo>', 'Create a Commit'
16
+ long_desc <<-DESC
17
+ Parameters
18
+
19
+ message - String of the commit message \n
20
+ tree - String of the SHA of the tree object this commit points to \n
21
+ parents - Array of the SHAs of the commits that were the parents of this commit. If omitted or empty, the commit will be written as a root commit. For a single parent, an array of one SHA should be provided, for a merge commit, an array of more than one should be provided. \n
22
+
23
+ Optional Parameters
24
+
25
+ The committer section is optional and will be filled with the author data if omitted. If the author section is omitted, it will be filled in with the authenticated users information and the current date.
26
+
27
+ author.name - String of the name of the author of the commit \n
28
+ author.email - String of the email of the author of the commit \n
29
+ author.date - Timestamp of when this commit was authored \n
30
+ committer.name - String of the name of the committer of the commit \n
31
+ committer.email - String of the email of the committer of the commit \n
32
+ committer.date:: Timestamp of when this commit was committed
33
+ DESC
16
34
  method_option :params, :type => :hash, :default => {},
17
35
  :desc => 'Additonal request parameters e.i per_page:100'
18
36
  def create(user, repo)
@@ -0,0 +1,67 @@
1
+ # encoding: utf-8
2
+
3
+ module GithubCLI
4
+ class Commands::Downloads < Command
5
+
6
+ namespace :download
7
+
8
+ desc 'list <user> <repo>', 'Lists downloads'
9
+ method_option :params, :type => :hash, :default => {},
10
+ :desc => 'Additional request parameters e.i per_page:100'
11
+ def list(user, repo)
12
+ Download.all user, repo, options[:params]
13
+ end
14
+
15
+ desc 'get <user> <repo> <id>', 'Get a download'
16
+ method_option :params, :type => :hash, :default => {},
17
+ :desc => 'Additional request parameters e.i per_page:100'
18
+ def get(user, repo, id)
19
+ Download.get user, repo, id, options[:params]
20
+ end
21
+
22
+ desc 'create <user> <repo>', 'Create a new download resource'
23
+ long_desc <<-DESC
24
+ Creating a new download is a two step process.
25
+
26
+ You must first create a new download resource using this method.
27
+ Response from this method is to be used in #upload method.
28
+
29
+ Inputs
30
+
31
+ name - Required string - name of the file that is being created. \n
32
+ size - Required number - size of file in bytes. \n
33
+ description - Optional string \n
34
+ content_type - Optional string \n
35
+ DESC
36
+ method_option :params, :type => :hash, :default => {},
37
+ :desc => 'Additonal request parameters e.i per_page:100'
38
+ def create(user, repo)
39
+ Download.create user, repo, options[:params]
40
+ end
41
+
42
+ desc 'upload <resource> <filename>', 'Upload resource to s3'
43
+ long_desc <<-DESC
44
+ Upload a file to Amazon, using the reponse instance from
45
+ Github::Repos::Downloads#create_download.
46
+
47
+ This can be done by passing the response object
48
+ as an argument to upload method.
49
+
50
+ Parameters
51
+
52
+ resource - Required resource of the create_download call. \n
53
+ filename - Required filename, a path to a file location. \n
54
+ DESC
55
+ def upload(resource, filename)
56
+ Download.upload resource, filename
57
+ end
58
+
59
+ desc 'delete <user> <repo> <id>', 'Delete a download'
60
+ method_option :params, :type => :hash, :default => {},
61
+ :desc => 'Additonal request parameters e.i per_page:100'
62
+ def delete(user, repo, id)
63
+ Download.delete user, repo, id, options[:params]
64
+ end
65
+
66
+ end # Downloads
67
+ end # GithubCLI
@@ -8,8 +8,10 @@ module GithubCLI
8
8
  desc 'list <user> <repo>', 'Lists forks'
9
9
  long_desc <<-DESC
10
10
  List repository forks
11
+
11
12
  Parameters
12
- sort - newest, oldest, watchers, default: newest
13
+
14
+ sort - newest, oldest, watchers, default: newest
13
15
  DESC
14
16
  method_option :sort, :type => :string, :aliases => ["-s"],
15
17
  :desc => 'Sort by newest, oldest or watchers',
@@ -23,7 +25,7 @@ module GithubCLI
23
25
  Fork.all user, repo, options[:params]
24
26
  end
25
27
 
26
- desc 'create <user> <repo>', 'Create a new Blob'
28
+ desc 'create <user> <repo>', 'Create a new fork'
27
29
  method_option :org, :type => :string,
28
30
  :desc => ' Organization login. The repository will be forked into this organization.'
29
31
  method_option :params, :type => :hash, :default => {},
@@ -0,0 +1,67 @@
1
+ # encoding: utf-8
2
+
3
+ module GithubCLI
4
+ class Commands::Hooks < Command
5
+
6
+ namespace :hook
7
+
8
+ desc 'list <user> <repo>', 'Lists hooks'
9
+ method_option :params, :type => :hash, :default => {},
10
+ :desc => 'Additional request parameters e.i per_page:100'
11
+ def list(user, repo)
12
+ Hook.all user, repo, options[:params]
13
+ end
14
+
15
+ desc 'get <user> <repo> <id>', 'Get a hook'
16
+ method_option :params, :type => :hash, :default => {},
17
+ :desc => 'Additional request parameters e.i per_page:100'
18
+ def get(user, repo, id)
19
+ Hook.get user, repo, id, options[:params]
20
+ end
21
+
22
+ desc 'create <user> <repo>', 'Create a hook'
23
+ long_desc <<-DESC
24
+ Inputs
25
+
26
+ name - Required string - the name of the service that is being called.\n
27
+ config - Required hash - A Hash containing key/value pairs to provide settings for this hook. \n
28
+ events - Optional array - Determines what events the hook is triggered for. Default: ["push"] \n
29
+ active - Optional boolean - Determines whether the hook is actually triggered on pushes.
30
+ DESC
31
+ method_option :params, :type => :hash, :default => {},
32
+ :desc => 'Additonal request parameters e.i per_page:100'
33
+ def create(user, repo)
34
+ Hook.create user, repo, options[:params]
35
+ end
36
+
37
+ desc 'edit <user> <repo> <id>', 'Edit a hook'
38
+ long_desc <<-DESC
39
+ Inputs
40
+
41
+ name - Required string - the name of the service that is being called. \n
42
+ config - Required hash - A Hash containing key/value pairs to provide settings for this hook. \n
43
+ events - Optional array - Determines what events the hook is triggered for. This replaces the entire array of events. Default: ["push"]. \n
44
+ add_events - Optional array - Determines a list of events to be added to the list of events that the Hook triggers for. \n
45
+ remove_events - Optional array - Determines a list of events to be removed from the list of events that the Hook triggers for. \n
46
+ active - Optional boolean - Determines whether the hook is actually triggered on pushes. \n
47
+ DESC
48
+ def edit(user, repo, id)
49
+ Hook.edit user, repo, id, options[:params]
50
+ end
51
+
52
+ desc 'test <user> <repo> <id>', 'Test a hook'
53
+ method_option :params, :type => :hash, :default => {},
54
+ :desc => 'Additonal request parameters e.i per_page:100'
55
+ def test(user, repo, id)
56
+ Hook.test user, repo, id, options[:params]
57
+ end
58
+
59
+ desc 'delete <user> <repo> <id>', 'Delete a hook'
60
+ method_option :params, :type => :hash, :default => {},
61
+ :desc => 'Additonal request parameters e.i per_page:100'
62
+ def delete(user, repo, id)
63
+ Hook.delete user, repo, id, options[:params]
64
+ end
65
+
66
+ end # Hooks
67
+ end # GithubCLI
@@ -0,0 +1,56 @@
1
+ # encoding: utf-8
2
+
3
+ module GithubCLI
4
+ class Commands::Keys < Command
5
+
6
+ namespace :key
7
+
8
+ desc 'list <user> <repo>', 'Lists keys'
9
+ method_option :params, :type => :hash, :default => {},
10
+ :desc => 'Additional request parameters e.i per_page:100'
11
+ def list(user, repo)
12
+ Key.all user, repo, options[:params]
13
+ end
14
+
15
+ desc 'get <user> <repo> <id>', 'Get a key'
16
+ method_option :params, :type => :hash, :default => {},
17
+ :desc => 'Additional request parameters e.i per_page:100'
18
+ def get(user, repo, id)
19
+ Key.get user, repo, id, options[:params]
20
+ end
21
+
22
+ desc 'create <user> <repo>', 'Create a new key'
23
+ long_desc <<-DESC
24
+ Inputs
25
+
26
+ title - Required string. \n
27
+ key - Required string.
28
+ DESC
29
+ method_option :params, :type => :hash, :default => {},
30
+ :desc => 'Additonal request parameters e.i per_page:100'
31
+ def create(user, repo)
32
+ Key.create user, repo, options[:params]
33
+ end
34
+
35
+ desc 'edit <user> <repo> <id>', 'Edit a key'
36
+ long_desc <<-DESC
37
+ Inputs
38
+
39
+ title - Required string. \n
40
+ key - Required string.
41
+ DESC
42
+ method_option :params, :type => :hash, :default => {},
43
+ :desc => 'Additonal request parameters e.i per_page:100'
44
+ def edit(user, repo, id)
45
+ Key.edit user, repo, id, options[:params]
46
+ end
47
+
48
+ desc 'delete <user> <repo> <id>', 'Delete a key'
49
+ method_option :params, :type => :hash, :default => {},
50
+ :desc => 'Additonal request parameters e.i per_page:100'
51
+ def delete(user, repo, id)
52
+ Key.delete user, repo, id, options[:params]
53
+ end
54
+
55
+ end # Keys
56
+ end # GithubCLI
@@ -5,13 +5,6 @@ module GithubCLI
5
5
 
6
6
  namespace :ref
7
7
 
8
- desc 'get <user> <repo> <ref>', 'Get a Reference'
9
- method_option :params, :type => :hash, :default => {},
10
- :desc => 'Additonal request parameters e.i per_page:100'
11
- def get(user, repo, ref)
12
- Reference.get user, repo, ref, options[:params]
13
- end
14
-
15
8
  desc 'list <user> <repo> <ref>', 'List all References'
16
9
  method_option :ref, :type => :string, :banner => 'branch reference'
17
10
  method_option :params, :type => :hash, :default => {},
@@ -21,7 +14,20 @@ module GithubCLI
21
14
  Reference.list user, repo, ref, options[:params]
22
15
  end
23
16
 
17
+ desc 'get <user> <repo> <ref>', 'Get a Reference'
18
+ method_option :params, :type => :hash, :default => {},
19
+ :desc => 'Additonal request parameters e.i per_page:100'
20
+ def get(user, repo, ref)
21
+ Reference.get user, repo, ref, options[:params]
22
+ end
23
+
24
24
  desc 'create <user> <repo>', 'Create a new Reference'
25
+ long_desc <<-DESC
26
+ Inputs
27
+
28
+ ref - String of the name of the fully qualified reference (ie: refs/heads/master). If it doesn’t start with ‘refs’ and have at least two slashes, it will be rejected.\n
29
+ sha - String of the SHA1 value to set this reference to
30
+ DESC
25
31
  method_option :params, :type => :hash, :default => {},
26
32
  :desc => 'Additonal request parameters e.i per_page:100'
27
33
  def create(user, repo)
@@ -29,6 +35,12 @@ module GithubCLI
29
35
  end
30
36
 
31
37
  desc 'update <user> <repo> <ref>', 'Update a Reference'
38
+ long_desc <<-DESC
39
+ Inputs
40
+
41
+ sha - String of the SHA1 value to set this reference to\n
42
+ force - Boolean indicating whether to force the update or to make sure the update is a fast-forward update. The default is <tt>false</tt>, so leaving this out or setting it to false will make sure you’re not overwriting work.
43
+ DESC
32
44
  method_option :params, :type => :hash, :default => {},
33
45
  :desc => 'Additonal request parameters e.i per_page:100'
34
46
  def update(user, repo, ref)
@@ -31,6 +31,21 @@ module GithubCLI
31
31
  end
32
32
 
33
33
  desc 'create', 'Create a new repository for the authenticated user.'
34
+ long_desc <<-DESC
35
+ Create a new repository for the autheticated user.
36
+
37
+ Parameters
38
+
39
+ name - Required string \n
40
+ description - Optional string \n
41
+ homepage - Optional string \n
42
+ private - Optional boolean - true to create a private repository, false to create a public one \n
43
+ has_issues - Optional boolean - true to enable issues for this repository, false to disable them \n
44
+ has_wiki - Optional boolean - true to enable the wiki for this repository, false to disable it. Default is true \n
45
+ has_downloads Optional boolean - true to enable downloads for this repository \n
46
+ org Optional string - The organisation in which this repository will be created \n
47
+ 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
48
+ DESC
34
49
  method_option :org, :type => :string, :aliases => ["-o"],
35
50
  :desc => 'Create repository in <organization>',
36
51
  :banner => '<organization>'
@@ -40,10 +55,23 @@ module GithubCLI
40
55
  if options[:org]
41
56
  options[:params]['org'] = options[:org]
42
57
  end
43
- Repository.create user, repo, options[:params]
58
+ Repository.create options[:params]
44
59
  end
45
60
 
46
61
  desc 'edit <user> <repo>', 'Edit <repo> for an <user>.'
62
+ long_desc <<-DESC
63
+ Create a new repository for the autheticated user.
64
+
65
+ Parameters
66
+
67
+ name - Required string \n
68
+ description - Optional string \n
69
+ homepage - Optional string \n
70
+ private - Optional boolean - true to create a private repository, false to create a public one \n
71
+ has_issues - Optional boolean - true to enable issues for this repository, false to disable them \n
72
+ has_wiki - Optional boolean - true to enable the wiki for this repository, false to disable it. Default is true \n
73
+ has_downloads Optional boolean - true to enable downloads for this repository \n
74
+ DESC
47
75
  method_option :params, :type => :hash, :default => {},
48
76
  :desc => 'Additonal request parameters e.i per_page:100'
49
77
  def edit(user, repo)
@@ -15,6 +15,23 @@ module GithubCLI
15
15
  end
16
16
 
17
17
  desc 'create <user> <repo>', 'Create a Tag Object'
18
+ long_desc <<-DESC
19
+ Note that creating a tag object does not create the reference that
20
+ makes a tag in Git. If you want to create an annotated tag in Git,
21
+ you have to do this call to create the tag object, and then create
22
+ the refs/tags/[tag] reference. If you want to create a lightweight tag,
23
+ you simply have to create the reference - this call would be unnecessary.
24
+
25
+ Parameters
26
+
27
+ tag - String of the tag \n
28
+ message - String of the tag message \n
29
+ object - String of the SHA of the git object this is tagging \n
30
+ type - String of the type of the object we're tagging. Normally this is a commit but it can also be a tree or a blob \n
31
+ tagger.name - String of the name of the author of the tag \n
32
+ tagger.email - String of the email of the author of the tag \n
33
+ tagger.date - Timestamp of when this object was tagged \n
34
+ DESC
18
35
  method_option :params, :type => :hash, :default => {},
19
36
  :desc => 'Additonal request parameters e.i per_page:100'
20
37
  def create(user, repo)
@@ -18,6 +18,22 @@ module GithubCLI
18
18
  end
19
19
 
20
20
  desc 'create <user> <repo>', 'Create a new Tree'
21
+ long_desc <<-DESC
22
+ The tree creation API will take nested entries as well.
23
+ If both a tree and a nested path modifying that tree are specified,
24
+ it will overwrite the contents of that tree with the new path contents
25
+ and write a new tree out.
26
+
27
+ Parameters
28
+
29
+ base_tree - optional string of the SHA1 of the tree you want to update with new data \n
30
+ tree - array of hash objects(of :path, :mode, :type and sha) \n
31
+ tree.path - String of the file referenced in the tree \n
32
+ tree.mode - String of the file mode - one of 100644 for file(blob), 100755 for executable (blob), 040000 for subdirectory (tree), 160000 for submodule (commit) or 120000 for a blob that specifies the path of a symlink \n
33
+ tree.type - String of blob, tree, commit \n
34
+ tree.sha - String of SHA1 checksum ID of the object in the tree
35
+ tree.content - String of content you want this file to have - GitHub will write this blob out and use the SHA for this entry. Use either this or tree.sha
36
+ DESC
21
37
  method_option :params, :type => :hash, :default => {},
22
38
  :desc => 'Additonal request parameters e.i per_page:100'
23
39
  def create(user, repo)
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ module GithubCLI
4
+ class Commands::Watching < Command
5
+
6
+ namespace :watch
7
+
8
+ desc 'watchers <user> <repo>', 'Lists repo watchers'
9
+ method_option :params, :type => :hash, :default => {},
10
+ :desc => 'Additional request parameters e.i per_page:100'
11
+ def watchers(user, repo)
12
+ Watching.watchers user, repo, options[:params]
13
+ end
14
+
15
+ desc 'watched', 'Lists repos being watched by a user'
16
+ method_option :user, :type => :string, :aliases => ["-u"],
17
+ :desc => 'Watch repositories for <user>'
18
+ method_option :params, :type => :hash, :default => {},
19
+ :desc => 'Additional request parameters e.i per_page:100'
20
+ def watched(user, repo, id)
21
+ if options[:user]
22
+ options[:params]['user'] = options[:user]
23
+ end
24
+ Watching.watched options[:params]
25
+ end
26
+
27
+ desc 'watching <user> <repo>', 'Check if you are watching a repository'
28
+ method_option :params, :type => :hash, :default => {},
29
+ :desc => 'Additonal request parameters e.i per_page:100'
30
+ def watching(user, repo)
31
+ Watching.watching? user, repo, options[:params]
32
+ end
33
+
34
+ desc 'start <user> <repo>', 'Watch a repository'
35
+ method_option :params, :type => :hash, :default => {},
36
+ :desc => 'Additonal request parameters e.i per_page:100'
37
+ def start(user, repo)
38
+ Watching.start_watching user, repo, options[:params]
39
+ end
40
+
41
+ desc 'stop <user> <repo>', 'Stop watching a repository'
42
+ method_option :params, :type => :hash, :default => {},
43
+ :desc => 'Additonal request parameters e.i per_page:100'
44
+ def stop(user, repo)
45
+ Watching.stop_watching user, repo, options[:params]
46
+ end
47
+
48
+ end # Watching
49
+ end # GithubCLI
@@ -17,7 +17,7 @@ module GithubCLI
17
17
  end
18
18
 
19
19
  def [](key)
20
- data[key] #|| data[COMMAND_KEY][key]
20
+ data[key] #|| (data.nil? ? nil : data[COMMAND_KEY][key])
21
21
  end
22
22
 
23
23
  def fetch(key, default=nil)
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ module GithubCLI
4
+ class CLI
5
+
6
+ desc "blob <command>", "Leverage Blobs API"
7
+ subcommand "blob", GithubCLI::Commands::Blobs
8
+
9
+ desc "commit <command>", "Leverage Commits API"
10
+ subcommand "commit", GithubCLI::Commands::Commits
11
+
12
+ desc "download <command>", "Leverage Downloads API"
13
+ subcommand "download", GithubCLI::Commands::Downloads
14
+
15
+ desc "fork <command>", "Leverage Forks API"
16
+ subcommand "fork", GithubCLI::Commands::Forks
17
+
18
+ desc "hook <command>", "Leverage Hooks API"
19
+ subcommand "hook", GithubCLI::Commands::Hooks
20
+
21
+ desc "issue <command>", "Leverage Issues API"
22
+ subcommand "issue", GithubCLI::Commands::Issues
23
+
24
+ desc "key <command>", "Leverage Keys API"
25
+ subcommand "key", GithubCLI::Commands::Keys
26
+
27
+ desc "label <command>", "Leverage Labels API"
28
+ subcommand "label", GithubCLI::Commands::Labels
29
+
30
+ desc "pull <command>", "Leverage Pull Requests API"
31
+ subcommand "pull", GithubCLI::Commands::PullRequests
32
+
33
+ desc "ref <command>", "Leverage References API"
34
+ subcommand "ref", GithubCLI::Commands::References
35
+
36
+ desc "repo <command>", "Leverage Repositories API"
37
+ subcommand "repo", GithubCLI::Commands::Repositories
38
+
39
+ desc "tag <command>", "Leverage Tags API"
40
+ subcommand "tag", GithubCLI::Commands::Tags
41
+
42
+ desc "tree <command>", "Leverage Trees API"
43
+ subcommand "tree", GithubCLI::Commands::Trees
44
+
45
+ desc "watch <command>", "Leverage Watching API"
46
+ subcommand "watch", GithubCLI::Commands::Watching
47
+
48
+ end # CLI
49
+ end # GithubCLI
@@ -1,3 +1,3 @@
1
1
  module GithubCLI
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -5,8 +5,14 @@ describe GithubCLI::Config do
5
5
  let(:config_name) { 'simple_config' }
6
6
  let(:path) { "/users/#{filename}" }
7
7
 
8
+ before :all do
9
+ unless File.exists?(fixture_path('.githubrc'))
10
+ File.symlink(fixture_path(config_name), fixture_path('.githubrc'))
11
+ end
12
+ end
13
+
8
14
  context 'global' do
9
- let(:config) { GithubCLI::Config.new fixture_path(config_name) }
15
+ let(:config) { GithubCLI::Config.new fixture_path }
10
16
 
11
17
  before do
12
18
  File.stub(:open) { YAML.load fixture('simple_config') }
@@ -14,6 +14,6 @@ def fixture(name)
14
14
  File.read File.expand_path File.join(File.dirname(__FILE__), '..', 'fixtures', name)
15
15
  end
16
16
 
17
- def fixture_path(name)
17
+ def fixture_path(name='')
18
18
  File.expand_path File.join(File.dirname(__FILE__), '..', 'fixtures', name)
19
19
  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.1.3
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-22 00:00:00.000000000 Z
12
+ date: 2012-04-29 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: github_api
16
- requirement: &2151931480 !ruby/object:Gem::Requirement
16
+ requirement: &2160315660 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 0.4.8
21
+ version: 0.5.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2151931480
24
+ version_requirements: *2160315660
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: thor
27
- requirement: &2151930740 !ruby/object:Gem::Requirement
27
+ requirement: &2160315120 !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: :runtime
34
34
  prerelease: false
35
- version_requirements: *2151930740
35
+ version_requirements: *2160315120
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &2151929860 !ruby/object:Gem::Requirement
38
+ requirement: &2160314500 !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: *2151929860
46
+ version_requirements: *2160314500
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: aruba
49
- requirement: &2151929040 !ruby/object:Gem::Requirement
49
+ requirement: &2160314000 !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: *2151929040
57
+ version_requirements: *2160314000
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rake
60
- requirement: &2151942440 !ruby/object:Gem::Requirement
60
+ requirement: &2160313480 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2151942440
68
+ version_requirements: *2160313480
69
69
  description: CLI-based access to GitHub API v3
70
70
  email:
71
71
  - pmurach@gmail.com
@@ -89,6 +89,7 @@ files:
89
89
  - features/settings.feature
90
90
  - features/support/env.rb
91
91
  - features/support/hooks.rb
92
+ - fixtures/.githubrc
92
93
  - fixtures/simple_config
93
94
  - github_cli.gemspec
94
95
  - lib/github_cli.rb
@@ -96,30 +97,39 @@ files:
96
97
  - lib/github_cli/apis.rb
97
98
  - lib/github_cli/apis/blob.rb
98
99
  - lib/github_cli/apis/commit.rb
100
+ - lib/github_cli/apis/download.rb
99
101
  - lib/github_cli/apis/fork.rb
102
+ - lib/github_cli/apis/hook.rb
103
+ - lib/github_cli/apis/key.rb
100
104
  - lib/github_cli/apis/label.rb
101
105
  - lib/github_cli/apis/pull_request.rb
102
106
  - lib/github_cli/apis/reference.rb
103
107
  - lib/github_cli/apis/repository.rb
104
108
  - lib/github_cli/apis/tag.rb
105
109
  - lib/github_cli/apis/tree.rb
110
+ - lib/github_cli/apis/watching.rb
106
111
  - lib/github_cli/cli.rb
107
112
  - lib/github_cli/command.rb
108
113
  - lib/github_cli/commands.rb
109
114
  - lib/github_cli/commands/blobs.rb
110
115
  - lib/github_cli/commands/commits.rb
116
+ - lib/github_cli/commands/downloads.rb
111
117
  - lib/github_cli/commands/forks.rb
118
+ - lib/github_cli/commands/hooks.rb
112
119
  - lib/github_cli/commands/issues.rb
120
+ - lib/github_cli/commands/keys.rb
113
121
  - lib/github_cli/commands/labels.rb
114
122
  - lib/github_cli/commands/pull_requests.rb
115
123
  - lib/github_cli/commands/references.rb
116
124
  - lib/github_cli/commands/repositories.rb
117
125
  - lib/github_cli/commands/tags.rb
118
126
  - lib/github_cli/commands/trees.rb
127
+ - lib/github_cli/commands/watching.rb
119
128
  - lib/github_cli/config.rb
120
129
  - lib/github_cli/dsl.rb
121
130
  - lib/github_cli/errors.rb
122
131
  - lib/github_cli/helpers.rb
132
+ - lib/github_cli/subcommands.rb
123
133
  - lib/github_cli/terminal.rb
124
134
  - lib/github_cli/ui.rb
125
135
  - lib/github_cli/version.rb