github_cli 0.4.0 → 0.4.1
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.
- data/.travis.yml +3 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +4 -4
- data/README.md +8 -1
- data/features/blob.feature +8 -0
- data/features/collaborator.feature +10 -0
- data/features/commit.feature +8 -0
- data/features/content.feature +9 -0
- data/features/gist.feature +15 -0
- data/features/pull_request.feature +14 -0
- data/features/search.feature +7 -30
- data/features/search_commands.feature +33 -0
- data/features/watching.feature +11 -0
- data/lib/github_cli/apis.rb +2 -0
- data/lib/github_cli/apis/content.rb +28 -0
- data/lib/github_cli/apis/search.rb +35 -0
- data/lib/github_cli/cli.rb +9 -5
- data/lib/github_cli/command.rb +2 -1
- data/lib/github_cli/commands.rb +2 -0
- data/lib/github_cli/commands/blobs.rb +0 -4
- data/lib/github_cli/commands/collaborators.rb +0 -8
- data/lib/github_cli/commands/commits.rb +0 -4
- data/lib/github_cli/commands/contents.rb +49 -0
- data/lib/github_cli/commands/downloads.rb +0 -8
- data/lib/github_cli/commands/emails.rb +0 -6
- data/lib/github_cli/commands/events.rb +0 -16
- data/lib/github_cli/commands/followers.rb +0 -10
- data/lib/github_cli/commands/forks.rb +0 -4
- data/lib/github_cli/commands/gists.rb +0 -18
- data/lib/github_cli/commands/hooks.rb +0 -10
- data/lib/github_cli/commands/issues.rb +0 -10
- data/lib/github_cli/commands/keys.rb +0 -10
- data/lib/github_cli/commands/labels.rb +0 -20
- data/lib/github_cli/commands/members.rb +0 -10
- data/lib/github_cli/commands/milestones.rb +0 -10
- data/lib/github_cli/commands/organizations.rb +0 -6
- data/lib/github_cli/commands/pull_requests.rb +0 -16
- data/lib/github_cli/commands/references.rb +0 -10
- data/lib/github_cli/commands/repositories.rb +0 -18
- data/lib/github_cli/commands/search.rb +39 -0
- data/lib/github_cli/commands/tags.rb +0 -4
- data/lib/github_cli/commands/teams.rb +0 -26
- data/lib/github_cli/commands/trees.rb +0 -4
- data/lib/github_cli/commands/users.rb +0 -4
- data/lib/github_cli/commands/watching.rb +0 -10
- data/lib/github_cli/subcommands.rb +6 -0
- data/lib/github_cli/version.rb +1 -1
- metadata +32 -12
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
github_cli (0.4.
|
4
|
+
github_cli (0.4.1)
|
5
5
|
github_api (~> 0.6)
|
6
6
|
thor
|
7
7
|
|
@@ -27,12 +27,12 @@ GEM
|
|
27
27
|
ffi (1.0.11)
|
28
28
|
gherkin (2.11.0)
|
29
29
|
json (>= 1.4.6)
|
30
|
-
github_api (0.6.
|
31
|
-
faraday (~> 0.8.
|
30
|
+
github_api (0.6.1)
|
31
|
+
faraday (~> 0.8.1)
|
32
32
|
hashie (~> 1.2.0)
|
33
33
|
multi_json (~> 1.3)
|
34
34
|
nokogiri (~> 1.5.2)
|
35
|
-
oauth2
|
35
|
+
oauth2
|
36
36
|
hashie (1.2.0)
|
37
37
|
httpauth (0.1)
|
38
38
|
json (1.7.3)
|
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# GithubCLI<img src="https://github.com/peter-murach/github_cli/raw/master/ghc_logo.png" align="right" />
|
2
|
-
[][travis] [][gemnasium]
|
2
|
+
[][travis] [][gemnasium] [][codeclimate]
|
3
3
|
|
4
4
|
[travis]: http://travis-ci.org/peter-murach/github_cli
|
5
5
|
[gemnasium]: https://gemnasium.com/peter-murach/github_cli
|
6
|
+
[codeclimate]: https://codeclimate.com/github/peter-murach/github_cli
|
6
7
|
|
7
8
|
CLI-based access to GitHub API v3 that works hand-in-hand with 'github_api' gem.
|
8
9
|
|
@@ -114,6 +115,12 @@ Interact with authorizations:
|
|
114
115
|
$ ghc auth
|
115
116
|
```
|
116
117
|
|
118
|
+
Interact with search:
|
119
|
+
|
120
|
+
```shell
|
121
|
+
$ ghc search
|
122
|
+
```
|
123
|
+
|
117
124
|
### Output Format
|
118
125
|
|
119
126
|
The API responses can be formatted as `csv`, `json`, `pretty`, `table`.
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Feature: ghc collab
|
2
|
+
|
3
|
+
Scenario: Available commands
|
4
|
+
|
5
|
+
When I run `ghc collab`
|
6
|
+
Then the exit status should be 0
|
7
|
+
And the output should contain "ghc collab list"
|
8
|
+
And the output should contain "ghc collab add"
|
9
|
+
And the output should contain "ghc collab collab"
|
10
|
+
And the output should contain "ghc collab remove"
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Feature: ghc content
|
2
|
+
|
3
|
+
Scenario: Available commands
|
4
|
+
|
5
|
+
When I run `ghc content`
|
6
|
+
Then the exit status should be 0
|
7
|
+
And the output should contain "ghc content get"
|
8
|
+
And the output should contain "ghc content readme"
|
9
|
+
And the output should contain "ghc content archive"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Feature: ghc gist
|
2
|
+
|
3
|
+
Scenario: Available commands
|
4
|
+
|
5
|
+
When I run `ghc gist`
|
6
|
+
Then the exit status should be 0
|
7
|
+
And the output should contain "ghc gist create"
|
8
|
+
And the output should contain "ghc gist delete"
|
9
|
+
And the output should contain "ghc gist edit"
|
10
|
+
And the output should contain "ghc gist get"
|
11
|
+
And the output should contain "ghc gist fork"
|
12
|
+
And the output should contain "ghc gist list"
|
13
|
+
And the output should contain "ghc gist star"
|
14
|
+
And the output should contain "ghc gist starred"
|
15
|
+
And the output should contain "ghc gist unstar"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Feature: ghc pull request
|
2
|
+
|
3
|
+
Scenario: Available commands
|
4
|
+
|
5
|
+
When I run `ghc pull`
|
6
|
+
Then the exit status should be 0
|
7
|
+
And the output should contain "ghc pull commits"
|
8
|
+
And the output should contain "ghc pull create"
|
9
|
+
And the output should contain "ghc pull files"
|
10
|
+
And the output should contain "ghc pull get"
|
11
|
+
And the output should contain "ghc pull list"
|
12
|
+
And the output should contain "ghc pull merge"
|
13
|
+
And the output should contain "ghc pull merged"
|
14
|
+
And the output should contain "ghc pull update"
|
data/features/search.feature
CHANGED
@@ -1,33 +1,10 @@
|
|
1
|
-
|
2
|
-
Feature: Github API Commands Search
|
1
|
+
Feature: ghc search
|
3
2
|
|
4
|
-
|
5
|
-
When I use interface provided by GHC
|
6
|
-
I have ability to list commands by search criteria
|
3
|
+
Scenario: Available commands
|
7
4
|
|
8
|
-
|
9
|
-
When I run `ghc list`
|
5
|
+
When I run `ghc search`
|
10
6
|
Then the exit status should be 0
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
Commands:
|
16
|
-
"""
|
17
|
-
|
18
|
-
Scenario Outline: Pattern Matching
|
19
|
-
When I run `ghc list <pattern>`
|
20
|
-
Then the output should contain "repo"
|
21
|
-
And the output should not contain "issue"
|
22
|
-
|
23
|
-
Examples:
|
24
|
-
| pattern |
|
25
|
-
| re |
|
26
|
-
| repo |
|
27
|
-
|
28
|
-
Scenario: No Match
|
29
|
-
When I run `ghc list bla`
|
30
|
-
Then the output should contain:
|
31
|
-
"""
|
32
|
-
ghc: 'bla' is not a ghc command. See 'ghc --help'.
|
33
|
-
"""
|
7
|
+
And the output should contain "ghc search email"
|
8
|
+
And the output should contain "ghc search issue"
|
9
|
+
And the output should contain "ghc search repo"
|
10
|
+
And the output should contain "ghc search user"
|
@@ -0,0 +1,33 @@
|
|
1
|
+
@search
|
2
|
+
Feature: Github API Commands Search
|
3
|
+
|
4
|
+
As a developer who wants to search for commands that leverage GitHub APIs
|
5
|
+
When I use interface provided by GHC
|
6
|
+
I have ability to list commands by search criteria
|
7
|
+
|
8
|
+
Scenario: Listing
|
9
|
+
When I run `ghc list`
|
10
|
+
Then the exit status should be 0
|
11
|
+
And the output should contain:
|
12
|
+
"""
|
13
|
+
Github CLI client
|
14
|
+
|
15
|
+
Commands:
|
16
|
+
"""
|
17
|
+
|
18
|
+
Scenario Outline: Pattern Matching
|
19
|
+
When I run `ghc list <pattern>`
|
20
|
+
Then the output should contain "repo"
|
21
|
+
And the output should not contain "issue"
|
22
|
+
|
23
|
+
Examples:
|
24
|
+
| pattern |
|
25
|
+
| re |
|
26
|
+
| repo |
|
27
|
+
|
28
|
+
Scenario: No Match
|
29
|
+
When I run `ghc list bla`
|
30
|
+
Then the output should contain:
|
31
|
+
"""
|
32
|
+
ghc: 'bla' is not a ghc command. See 'ghc --help'.
|
33
|
+
"""
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Feature: ghc watching
|
2
|
+
|
3
|
+
Scenario: Available commands
|
4
|
+
|
5
|
+
When I run `ghc watch`
|
6
|
+
Then the exit status should be 0
|
7
|
+
And the output should contain "ghc watch start"
|
8
|
+
And the output should contain "ghc watch stop"
|
9
|
+
And the output should contain "ghc watch watched"
|
10
|
+
And the output should contain "ghc watch watchers"
|
11
|
+
And the output should contain "ghc watch watching"
|
data/lib/github_cli/apis.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module GithubCLI
|
4
|
+
class Content < API
|
5
|
+
|
6
|
+
class << self
|
7
|
+
|
8
|
+
def get(user, repo, path, params, format)
|
9
|
+
output format do
|
10
|
+
github_api.repos.contents.get user, repo, path, params
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def readme(user, repo, params, format)
|
15
|
+
output format do
|
16
|
+
github_api.repos.contents.readme user, repo, params
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def archive(user, repo, params, format)
|
21
|
+
output format do
|
22
|
+
github_api.repos.contents.archive user, repo, params
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end # Content
|
28
|
+
end # GithubCLI
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module GithubCLI
|
4
|
+
class Search < API
|
5
|
+
|
6
|
+
class << self
|
7
|
+
|
8
|
+
def issue(owner, repo, keyword, params, format)
|
9
|
+
output format do
|
10
|
+
github_api.search.issues params.update(:owner => owner, :repo => repo, :keyword => keyword)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def repo(params, format)
|
15
|
+
output format do
|
16
|
+
github_api.search.repos params
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def user(params, format)
|
21
|
+
output format do
|
22
|
+
github_api.search.users params
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def email(params, format)
|
27
|
+
output format do
|
28
|
+
github_api.search.email params
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end # Search
|
35
|
+
end # GithubCLI
|
data/lib/github_cli/cli.rb
CHANGED
@@ -13,11 +13,15 @@ module GithubCLI
|
|
13
13
|
options["no-pager"] ? Pager.disable : Pager.enable
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
ALIASES = {
|
17
|
+
'repository' => 'repo',
|
18
|
+
'reference' => 'ref',
|
19
|
+
'is' => :issue,
|
20
|
+
'--version' => 'version',
|
21
|
+
'ls' => 'list'
|
22
|
+
}
|
23
|
+
|
24
|
+
map ALIASES
|
21
25
|
|
22
26
|
class_option :config, :type => :string,
|
23
27
|
:desc => "Configuration file.", :banner => "Config file name",
|
data/lib/github_cli/command.rb
CHANGED
@@ -6,13 +6,14 @@ module GithubCLI
|
|
6
6
|
|
7
7
|
API_CLASSES = %w(
|
8
8
|
c_l_i
|
9
|
-
repo download key fork hook watch collab
|
9
|
+
repo download key fork hook watch collab content
|
10
10
|
issue label milestone
|
11
11
|
tag tree blob reference commit
|
12
12
|
pull
|
13
13
|
user email follower
|
14
14
|
org member team
|
15
15
|
event
|
16
|
+
search
|
16
17
|
)
|
17
18
|
|
18
19
|
HELP_COMMAND = 'help'
|
data/lib/github_cli/commands.rb
CHANGED
@@ -6,6 +6,7 @@ module GithubCLI
|
|
6
6
|
autoload :Blobs, 'github_cli/commands/blobs'
|
7
7
|
autoload :Collaborators, 'github_cli/commands/collaborators'
|
8
8
|
autoload :Commits, 'github_cli/commands/commits'
|
9
|
+
autoload :Contents, 'github_cli/commands/contents'
|
9
10
|
autoload :Downloads, 'github_cli/commands/downloads'
|
10
11
|
autoload :Emails, 'github_cli/commands/emails'
|
11
12
|
autoload :Events, 'github_cli/commands/events'
|
@@ -22,6 +23,7 @@ module GithubCLI
|
|
22
23
|
autoload :PullRequests, 'github_cli/commands/pull_requests'
|
23
24
|
autoload :References, 'github_cli/commands/references'
|
24
25
|
autoload :Repositories, 'github_cli/commands/repositories'
|
26
|
+
autoload :Search, 'github_cli/commands/search'
|
25
27
|
autoload :Tags, 'github_cli/commands/tags'
|
26
28
|
autoload :Teams, 'github_cli/commands/teams'
|
27
29
|
autoload :Trees, 'github_cli/commands/trees'
|
@@ -6,8 +6,6 @@ module GithubCLI
|
|
6
6
|
namespace :blob
|
7
7
|
|
8
8
|
desc 'get <user> <repo> <sha>', 'Get a Blob'
|
9
|
-
method_option :params, :type => :hash, :default => {},
|
10
|
-
:desc => 'Additonal request parameters e.i per_page:100'
|
11
9
|
def get(user, repo, sha)
|
12
10
|
Blob.get user, repo, sha, options[:params], options[:format]
|
13
11
|
end
|
@@ -19,8 +17,6 @@ module GithubCLI
|
|
19
17
|
content - String of content \n
|
20
18
|
encoding - String containing encoding utf-8 or base64
|
21
19
|
DESC
|
22
|
-
method_option :params, :type => :hash, :default => {},
|
23
|
-
:desc => 'Additonal request parameters e.i per_page:100'
|
24
20
|
def create(user, repo)
|
25
21
|
Blob.create user, repo, options[:params], options[:format]
|
26
22
|
end
|
@@ -6,29 +6,21 @@ module GithubCLI
|
|
6
6
|
namespace :collab
|
7
7
|
|
8
8
|
desc 'list <user> <repo>', 'Lists collaborators'
|
9
|
-
method_option :params, :type => :hash, :default => {},
|
10
|
-
:desc => 'Additional request parameters e.i per_page:100'
|
11
9
|
def list(user, repo)
|
12
10
|
Collaborator.all user, repo, options[:params], options[:format]
|
13
11
|
end
|
14
12
|
|
15
13
|
desc 'add <user> <repo> <collab>', 'Add a collaborator'
|
16
|
-
method_option :params, :type => :hash, :default => {},
|
17
|
-
:desc => 'Additional request parameters e.i per_page:100'
|
18
14
|
def add(user, repo, collab)
|
19
15
|
Collaborator.add user, repo, collab, options[:params], options[:format]
|
20
16
|
end
|
21
17
|
|
22
18
|
desc 'collab <user> <repo> <collab>', 'Checks if user is a collaborator on a given repo'
|
23
|
-
method_option :params, :type => :hash, :default => {},
|
24
|
-
:desc => 'Additional request parameters e.i per_page:100'
|
25
19
|
def collab(user, repo, collab)
|
26
20
|
Collaborator.collaborator? user, repo, collab, options[:params], options[:format]
|
27
21
|
end
|
28
22
|
|
29
23
|
desc 'remove <user> <repo> <id>', 'Remove a collaborator'
|
30
|
-
method_option :params, :type => :hash, :default => {},
|
31
|
-
:desc => 'Additonal request parameters e.i per_page:100'
|
32
24
|
def remove(user, repo, collab)
|
33
25
|
Collaborator.remove user, repo, collab, options[:params]. options[:format]
|
34
26
|
end
|
@@ -6,8 +6,6 @@ module GithubCLI
|
|
6
6
|
namespace :commit
|
7
7
|
|
8
8
|
desc 'get <user> <repo> <sha>', 'Get a Commit'
|
9
|
-
method_option :params, :type => :hash, :default => {},
|
10
|
-
:desc => 'Additonal request parameters e.i per_page:100'
|
11
9
|
def get(user, repo, sha)
|
12
10
|
Commit.get user, repo, sha, options[:params], options[:format]
|
13
11
|
end
|
@@ -31,8 +29,6 @@ module GithubCLI
|
|
31
29
|
committer.email - String of the email of the committer of the commit \n
|
32
30
|
committer.date:: Timestamp of when this commit was committed
|
33
31
|
DESC
|
34
|
-
method_option :params, :type => :hash, :default => {},
|
35
|
-
:desc => 'Additonal request parameters e.i per_page:100'
|
36
32
|
def create(user, repo)
|
37
33
|
Commit.create user, repo, options[:params], options[:format]
|
38
34
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module GithubCLI
|
4
|
+
class Commands::Contents < Command
|
5
|
+
|
6
|
+
namespace :content
|
7
|
+
|
8
|
+
desc 'get <user> <repo> <path>', 'Get repository <path> contents'
|
9
|
+
long_desc <<-DESC
|
10
|
+
This method returns the contents of any file or directory in a repository.
|
11
|
+
|
12
|
+
Parameters
|
13
|
+
|
14
|
+
ref - Optional string - The String name of the Commit/Branch/Tag. Defaults to master.
|
15
|
+
DESC
|
16
|
+
def get(user, repo, path)
|
17
|
+
Content.get user, repo, path, options[:params], options[:format]
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'readme <user> <repo>', 'Get the README'
|
21
|
+
long_desc <<-DESC
|
22
|
+
Parameters
|
23
|
+
|
24
|
+
ref - Optional string - The String name of the Commit/Branch/Tag. Defaults to master.
|
25
|
+
DESC
|
26
|
+
def readme(user, repo)
|
27
|
+
Content.readme user, repo, options[:params], options[:format]
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'archive <user> <repo>', 'Get archive link'
|
31
|
+
long_desc <<-DESC
|
32
|
+
This method will return a 302 to a URL to download a tarball or zipball
|
33
|
+
archive for a repository. Please make sure your HTTP framework is configured
|
34
|
+
to follow redirects or you will need to use the Location header to make
|
35
|
+
a second GET request.\n
|
36
|
+
|
37
|
+
Note: For private repositories, these links are temporary and expire quickly.
|
38
|
+
|
39
|
+
Parameters
|
40
|
+
|
41
|
+
archive_format - Required string - either tarball or zipball\n
|
42
|
+
ref - Optional string - valid Git reference, defaults to master\n
|
43
|
+
DESC
|
44
|
+
def archive(user, repo)
|
45
|
+
Content.archive user, repo, options[:params], options[:format]
|
46
|
+
end
|
47
|
+
|
48
|
+
end # Contents
|
49
|
+
end # GithubCLI
|