github_cli 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +21 -0
- data/Gemfile.lock +20 -22
- data/README.md +29 -4
- data/bin/ghc +1 -1
- data/features/download.feature +11 -0
- data/features/email.feature +9 -0
- data/features/errors.feature +10 -0
- data/features/event.feature +14 -0
- data/features/executable.feature +44 -17
- data/features/follower.feature +11 -0
- data/features/fork.feature +13 -0
- data/features/hook.feature +12 -0
- data/features/label.feature +16 -0
- data/features/member.feature +18 -0
- data/features/milestone.feature +11 -0
- data/features/organization.feature +9 -0
- data/features/reference.feature +11 -0
- data/features/repositories.feature +16 -7
- data/features/tag.feature +8 -0
- data/features/team.feature +18 -0
- data/features/tree.feature +8 -0
- data/features/user.feature +8 -0
- data/ghc_logo.png +0 -0
- data/github_cli.gemspec +2 -2
- data/lib/github_cli/api.rb +14 -11
- data/lib/github_cli/apis/follower.rb +40 -0
- data/lib/github_cli/apis/member.rb +52 -0
- data/lib/github_cli/apis/organization.rb +28 -0
- data/lib/github_cli/apis/team.rb +89 -0
- data/lib/github_cli/apis/user.rb +22 -0
- data/lib/github_cli/apis.rb +5 -0
- data/lib/github_cli/cli.rb +11 -4
- data/lib/github_cli/command.rb +40 -28
- data/lib/github_cli/commands/followers.rb +50 -0
- data/lib/github_cli/commands/members.rb +70 -0
- data/lib/github_cli/commands/organizations.rb +42 -0
- data/lib/github_cli/commands/teams.rb +148 -0
- data/lib/github_cli/commands/users.rb +26 -0
- data/lib/github_cli/commands.rb +5 -0
- data/lib/github_cli/editor.rb +27 -0
- data/lib/github_cli/errors.rb +6 -1
- data/lib/github_cli/formatter.rb +47 -0
- data/lib/github_cli/formatters/csv.rb +8 -8
- data/lib/github_cli/formatters/table.rb +237 -11
- data/lib/github_cli/pager.rb +66 -0
- data/lib/github_cli/subcommands.rb +15 -0
- data/lib/github_cli/system.rb +33 -0
- data/lib/github_cli/terminal.rb +60 -30
- data/lib/github_cli/thor_ext.rb +15 -0
- data/lib/github_cli/ui.rb +8 -0
- data/lib/github_cli/util.rb +55 -12
- data/lib/github_cli/version.rb +1 -1
- data/lib/github_cli.rb +3 -0
- data/spec/github_cli/pager_spec.rb +69 -0
- data/spec/github_cli/util_spec.rb +14 -4
- metadata +64 -14
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
0.4.0 (June 15, 2012)
|
2
|
+
|
3
|
+
* Add user api commands.
|
4
|
+
* Add user followers api commands.
|
5
|
+
* Add organizations api commands.
|
6
|
+
* Add organization members api commands.
|
7
|
+
* Add organization teams api commands.
|
8
|
+
* Add gem logo.
|
9
|
+
* Add system configuration utilities.
|
10
|
+
* Add response pager to automatically paginate long output with ability to switch
|
11
|
+
it off as well as specify custom pager command.
|
12
|
+
* Fix issue with output formatting when simple string response is returned.
|
13
|
+
* Add interface feature tests.
|
14
|
+
* Add printing of command usage information.
|
15
|
+
* Refactor utility methods.
|
16
|
+
* Add new formatter for the output rendering.
|
17
|
+
* Refactor table & csv output, add vertical & horizontal table rendering.
|
18
|
+
* Add utility methods for string truncation and padding.
|
19
|
+
* Add ability to output to editor.
|
20
|
+
* Update gem dependecies and gem summary.
|
21
|
+
|
1
22
|
0.3.1 (May 30, 2012)
|
2
23
|
|
3
24
|
* Add milestone api commands.
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
github_cli (0.
|
5
|
-
github_api (~> 0.
|
4
|
+
github_cli (0.4.0)
|
5
|
+
github_api (~> 0.6)
|
6
6
|
thor
|
7
7
|
|
8
8
|
GEM
|
@@ -14,21 +14,20 @@ GEM
|
|
14
14
|
ffi (>= 1.0.11)
|
15
15
|
rspec (>= 2.7.0)
|
16
16
|
builder (3.0.0)
|
17
|
-
childprocess (0.3.
|
17
|
+
childprocess (0.3.2)
|
18
18
|
ffi (~> 1.0.6)
|
19
|
-
cucumber (1.1
|
19
|
+
cucumber (1.2.1)
|
20
20
|
builder (>= 2.1.2)
|
21
|
-
diff-lcs (>= 1.1.
|
22
|
-
gherkin (~> 2.
|
21
|
+
diff-lcs (>= 1.1.3)
|
22
|
+
gherkin (~> 2.11.0)
|
23
23
|
json (>= 1.4.6)
|
24
|
-
term-ansicolor (>= 1.0.6)
|
25
24
|
diff-lcs (1.1.3)
|
26
|
-
faraday (0.8.
|
25
|
+
faraday (0.8.1)
|
27
26
|
multipart-post (~> 1.1)
|
28
27
|
ffi (1.0.11)
|
29
|
-
gherkin (2.
|
28
|
+
gherkin (2.11.0)
|
30
29
|
json (>= 1.4.6)
|
31
|
-
github_api (0.
|
30
|
+
github_api (0.6.0)
|
32
31
|
faraday (~> 0.8.0)
|
33
32
|
hashie (~> 1.2.0)
|
34
33
|
multi_json (~> 1.3)
|
@@ -36,10 +35,10 @@ GEM
|
|
36
35
|
oauth2 (~> 0.7)
|
37
36
|
hashie (1.2.0)
|
38
37
|
httpauth (0.1)
|
39
|
-
json (1.
|
40
|
-
multi_json (1.3.
|
38
|
+
json (1.7.3)
|
39
|
+
multi_json (1.3.6)
|
41
40
|
multipart-post (1.1.5)
|
42
|
-
nokogiri (1.5.
|
41
|
+
nokogiri (1.5.3)
|
43
42
|
oauth2 (0.7.1)
|
44
43
|
faraday (~> 0.8)
|
45
44
|
httpauth (~> 0.1)
|
@@ -47,15 +46,14 @@ GEM
|
|
47
46
|
rack (~> 1.4)
|
48
47
|
rack (1.4.1)
|
49
48
|
rake (0.9.2.2)
|
50
|
-
rspec (2.
|
51
|
-
rspec-core (~> 2.
|
52
|
-
rspec-expectations (~> 2.
|
53
|
-
rspec-mocks (~> 2.
|
54
|
-
rspec-core (2.
|
55
|
-
rspec-expectations (2.
|
56
|
-
diff-lcs (~> 1.1.
|
57
|
-
rspec-mocks (2.
|
58
|
-
term-ansicolor (1.0.7)
|
49
|
+
rspec (2.10.0)
|
50
|
+
rspec-core (~> 2.10.0)
|
51
|
+
rspec-expectations (~> 2.10.0)
|
52
|
+
rspec-mocks (~> 2.10.0)
|
53
|
+
rspec-core (2.10.1)
|
54
|
+
rspec-expectations (2.10.0)
|
55
|
+
diff-lcs (~> 1.1.3)
|
56
|
+
rspec-mocks (2.10.1)
|
59
57
|
thor (0.15.2)
|
60
58
|
|
61
59
|
PLATFORMS
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# GithubCLI
|
1
|
+
# GithubCLI<img src="https://github.com/peter-murach/github_cli/raw/master/ghc_logo.png" align="right" />
|
2
2
|
[![Build Status](https://secure.travis-ci.org/peter-murach/github_cli.png?branch=master)][travis] [![Dependency Status](https://gemnasium.com/peter-murach/github_cli.png?travis)][gemnasium]
|
3
3
|
|
4
4
|
[travis]: http://travis-ci.org/peter-murach/github_cli
|
@@ -95,10 +95,19 @@ $ ghc gist
|
|
95
95
|
Interact with users:
|
96
96
|
|
97
97
|
```shell
|
98
|
+
$ ghc user
|
98
99
|
$ ghc email
|
99
100
|
$ ghc follower
|
100
101
|
```
|
101
102
|
|
103
|
+
Interact with organizations:
|
104
|
+
|
105
|
+
```shell
|
106
|
+
$ ghc org
|
107
|
+
$ ghc member
|
108
|
+
$ ghc team
|
109
|
+
```
|
110
|
+
|
102
111
|
Interact with authorizations:
|
103
112
|
|
104
113
|
```shell
|
@@ -107,12 +116,18 @@ $ ghc auth
|
|
107
116
|
|
108
117
|
### Output Format
|
109
118
|
|
110
|
-
The API responses can be
|
119
|
+
The API responses can be formatted as `csv`, `json`, `pretty`, `table`.
|
111
120
|
|
112
|
-
By default responses are in tabular format.
|
121
|
+
By default responses are in tabular format. Tables are available in `horizontal` and `vertical` mode. To enforce table display pass `:h` and `:v` respectively. Otherwise a default orientation will be picked depending on the request made and terminal size.
|
113
122
|
|
114
123
|
```shell
|
115
|
-
ghc
|
124
|
+
ghc user get -u peter-murach --format=table:h
|
125
|
+
|
126
|
+
┏━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━┳
|
127
|
+
┃ type ┃ login ┃ public_… ┃ blog ┃ hireable ┃ followe… ┃ followi… ┃ location ┃ html_url ┃ name ┃
|
128
|
+
┣━━━━━━━━━━╋━━━━━━━━━━╋━━━━━━━━━━╋━━━━━━━━━━╋━━━━━━━━━━╋━━━━━━━━━━╋━━━━━━━━━━╋━━━━━━━━━━╋━━━━━━━━━━╋━━━━━━━━━━╋
|
129
|
+
┃ User ┃ peter-m… ┃ 14 ┃ peter-m… ┃ false ┃ 18 ┃ 52 ┃ Sheffie… ┃ https:/… ┃ Piotr M… ┃
|
130
|
+
┗━━━━━━━━━━┻━━━━━━━━━━┻━━━━━━━━━━┻━━━━━━━━━━┻━━━━━━━━━━┻━━━━━━━━━━┻━━━━━━━━━━┻━━━━━━━━━━┻━━━━━━━━━━┻━━━━━━━━━━┻
|
116
131
|
```
|
117
132
|
|
118
133
|
To get `csv` formatting for easy command piping do
|
@@ -121,6 +136,16 @@ To get `csv` formatting for easy command piping do
|
|
121
136
|
ghc repo ls -u wycats --format=csv
|
122
137
|
```
|
123
138
|
|
139
|
+
### Output Paging
|
140
|
+
|
141
|
+
By default all responses are paged. You can switch off paging by supplying `no-pager` flag.
|
142
|
+
|
143
|
+
```shell
|
144
|
+
ghc --no-pager user ls -u wycats
|
145
|
+
```
|
146
|
+
|
147
|
+
Also you can supply you preferred `pager`, otherwise the paging program is taken from environment variable PAGER if defined or defaults to "less".
|
148
|
+
|
124
149
|
### Examples
|
125
150
|
|
126
151
|
You can create repository by supplying required parameters
|
data/bin/ghc
CHANGED
@@ -12,7 +12,7 @@ rescue Interrupt => e
|
|
12
12
|
rescue SystemExit => e
|
13
13
|
exit e.status
|
14
14
|
rescue Exception => e
|
15
|
-
GithubCLI.ui.error "Fatal error has occurred." + e.message
|
15
|
+
GithubCLI.ui.error "Fatal error has occurred. " + e.message
|
16
16
|
GithubCLI.ui.debug e.backtrace.join("\n")
|
17
17
|
exit 1
|
18
18
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Feature: ghc download
|
2
|
+
|
3
|
+
Scenario: Available commands
|
4
|
+
|
5
|
+
When I run `ghc download`
|
6
|
+
Then the exit status should be 0
|
7
|
+
And the output should contain "ghc download create"
|
8
|
+
And the output should contain "ghc download delete"
|
9
|
+
And the output should contain "ghc download get"
|
10
|
+
And the output should contain "ghc download list"
|
11
|
+
And the output should contain "ghc download upload"
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Feature: ghc errors notification
|
2
|
+
|
3
|
+
Scenario: Unknown formatting option
|
4
|
+
|
5
|
+
When I run `ghc repo list -u wycats --format=unknown`
|
6
|
+
Then the exit status should be 1
|
7
|
+
And the output should contain:
|
8
|
+
"""
|
9
|
+
Fatal error has occurred. Unrecognized formatting options: unknown
|
10
|
+
"""
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Feature: ghc event
|
2
|
+
|
3
|
+
Scenario: Available commands
|
4
|
+
|
5
|
+
When I run `ghc event`
|
6
|
+
Then the exit status should be 0
|
7
|
+
And the output should contain "ghc event issue"
|
8
|
+
And the output should contain "ghc event network"
|
9
|
+
And the output should contain "ghc event org"
|
10
|
+
And the output should contain "ghc event performed"
|
11
|
+
And the output should contain "ghc event public"
|
12
|
+
And the output should contain "ghc event received"
|
13
|
+
And the output should contain "ghc event repo"
|
14
|
+
And the output should contain "ghc event user_org"
|
data/features/executable.feature
CHANGED
@@ -6,32 +6,59 @@ Feature: The GHC Executable
|
|
6
6
|
I have access to command line interface
|
7
7
|
|
8
8
|
Scenario Outline: Getting Help for Commands
|
9
|
-
|
9
|
+
|
10
|
+
When I run `ghc <cmd>`
|
10
11
|
Then the exit status should be 0
|
11
12
|
And the output should contain:
|
12
13
|
"""
|
13
|
-
ghc help
|
14
|
+
ghc help <command>
|
14
15
|
"""
|
15
16
|
Examples:
|
16
|
-
|
|
17
|
-
|
|
18
|
-
| help
|
17
|
+
| cmd |
|
18
|
+
| |
|
19
|
+
| help |
|
20
|
+
|
21
|
+
Scenario: Getting Usage for Commands
|
22
|
+
|
23
|
+
When I run `ghc`
|
24
|
+
Then the exit status should be 0
|
25
|
+
And the output should contain "Usage: ghc"
|
26
|
+
And the output should contain "[--config]"
|
27
|
+
And the output should contain "[--no-color]"
|
28
|
+
And the output should contain "[--no-pager]"
|
29
|
+
And the output should contain "[--version]"
|
30
|
+
And the output should contain "[--verbose]"
|
19
31
|
|
20
32
|
Scenario Outline: Getting Subcommands
|
33
|
+
|
21
34
|
When I run `ghc <command>`
|
22
35
|
Then the exit status should be 0
|
23
36
|
And the output should contain "ghc <command>"
|
24
37
|
|
25
38
|
Examples:
|
26
|
-
| command
|
27
|
-
| auth
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
| fork
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
| command |
|
40
|
+
| auth |
|
41
|
+
| blob |
|
42
|
+
| commit |
|
43
|
+
| download |
|
44
|
+
| email |
|
45
|
+
| event |
|
46
|
+
| follower |
|
47
|
+
| fork |
|
48
|
+
| gist |
|
49
|
+
| hook |
|
50
|
+
| issue |
|
51
|
+
| key |
|
52
|
+
| label |
|
53
|
+
| member |
|
54
|
+
| milestone |
|
55
|
+
| org |
|
56
|
+
| pull |
|
57
|
+
| ref |
|
58
|
+
| repo |
|
59
|
+
| tag |
|
60
|
+
| team |
|
61
|
+
| tree |
|
62
|
+
| user |
|
63
|
+
| watch |
|
64
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Feature: ghc follower
|
2
|
+
|
3
|
+
Scenario: Available commands
|
4
|
+
|
5
|
+
When I run `ghc follower`
|
6
|
+
Then the exit status should be 0
|
7
|
+
And the output should contain "ghc follower follow"
|
8
|
+
And the output should contain "ghc follower follower"
|
9
|
+
And the output should contain "ghc follower following"
|
10
|
+
And the output should contain "ghc follower list"
|
11
|
+
And the output should contain "ghc follower unfollow"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Feature: ghc fork
|
2
|
+
|
3
|
+
Scenario: Available commands
|
4
|
+
|
5
|
+
When I run `ghc fork`
|
6
|
+
Then the exit status should be 0
|
7
|
+
And the output should contain "ghc fork create"
|
8
|
+
And the output should contain "ghc fork list"
|
9
|
+
|
10
|
+
# Scenario: List forks
|
11
|
+
# When I run `ghc fork ls wycats thor` interactively
|
12
|
+
# And I type "q"
|
13
|
+
# Then the exit status should be 0
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Feature: ghc hook
|
2
|
+
|
3
|
+
Scenario: Available commands
|
4
|
+
|
5
|
+
When I run `ghc hook`
|
6
|
+
Then the exit status should be 0
|
7
|
+
And the output should contain "ghc hook create"
|
8
|
+
And the output should contain "ghc hook delete"
|
9
|
+
And the output should contain "ghc hook edit"
|
10
|
+
And the output should contain "ghc hook get"
|
11
|
+
And the output should contain "ghc hook list"
|
12
|
+
And the output should contain "ghc hook test"
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Feature: ghc label
|
2
|
+
|
3
|
+
Scenario: Available commands
|
4
|
+
|
5
|
+
When I run `ghc label`
|
6
|
+
Then the exit status should be 0
|
7
|
+
And the output should contain "ghc label add"
|
8
|
+
And the output should contain "ghc label create"
|
9
|
+
And the output should contain "ghc label delete"
|
10
|
+
And the output should contain "ghc label get"
|
11
|
+
And the output should contain "ghc label issue"
|
12
|
+
And the output should contain "ghc label list"
|
13
|
+
And the output should contain "ghc label milestone"
|
14
|
+
And the output should contain "ghc label remove"
|
15
|
+
And the output should contain "ghc label replace"
|
16
|
+
And the output should contain "ghc label update"
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Feature: ghc member
|
2
|
+
|
3
|
+
Scenario: Available commands
|
4
|
+
|
5
|
+
When I run `ghc member`
|
6
|
+
Then the exit status should be 0
|
7
|
+
And the output should contain "ghc member delete"
|
8
|
+
And the output should contain "ghc member list"
|
9
|
+
And the output should contain "ghc member member"
|
10
|
+
And the output should contain "ghc member publicize"
|
11
|
+
|
12
|
+
# Scenario: List an organization members
|
13
|
+
# When I run `ghc member ls rails`
|
14
|
+
# Then the exit status should be 0
|
15
|
+
#
|
16
|
+
# Scenario: List an organization public members
|
17
|
+
# When I run `ghc member ls rails --public`
|
18
|
+
# Then the exit status should be 0
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Feature: ghc milestone
|
2
|
+
|
3
|
+
Scenario: Available commands
|
4
|
+
|
5
|
+
When I run `ghc milestone`
|
6
|
+
Then the exit status should be 0
|
7
|
+
And the output should contain "ghc milestone create"
|
8
|
+
And the output should contain "ghc milestone delete"
|
9
|
+
And the output should contain "ghc milestone get"
|
10
|
+
And the output should contain "ghc milestone list"
|
11
|
+
And the output should contain "ghc milestone update"
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Feature: ghc ref
|
2
|
+
|
3
|
+
Scenario: Available commands
|
4
|
+
|
5
|
+
When I run `ghc ref`
|
6
|
+
Then the exit status should be 0
|
7
|
+
And the output should contain "ghc ref create"
|
8
|
+
And the output should contain "ghc ref delete"
|
9
|
+
And the output should contain "ghc ref get"
|
10
|
+
And the output should contain "ghc ref list"
|
11
|
+
And the output should contain "ghc ref update"
|
@@ -1,9 +1,18 @@
|
|
1
|
-
|
2
|
-
Feature: Repository Commands
|
1
|
+
Feature: gh repository
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
Scenario: List repositories
|
8
|
-
When I run `ghc repo list --user=wycats`
|
3
|
+
Scenario: Available commands
|
4
|
+
When I run `ghc repo`
|
9
5
|
Then the exit status should be 0
|
6
|
+
And the output should contain "ghc repo branches"
|
7
|
+
And the output should contain "ghc repo contribs"
|
8
|
+
And the output should contain "ghc repo create"
|
9
|
+
And the output should contain "ghc repo edit"
|
10
|
+
And the output should contain "ghc repo get"
|
11
|
+
And the output should contain "ghc repo list"
|
12
|
+
And the output should contain "ghc repo languages"
|
13
|
+
And the output should contain "ghc repo tags"
|
14
|
+
And the output should contain "ghc repo teams"
|
15
|
+
|
16
|
+
# Scenario: List repositories
|
17
|
+
# When I run `ghc repo ls --user=wycats`
|
18
|
+
# Then the exit status should be 0
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Feature: ghc team
|
2
|
+
|
3
|
+
Scenario: Available commands
|
4
|
+
When I run `ghc team`
|
5
|
+
Then the exit status should be 0
|
6
|
+
And the output should contain "ghc team add_member"
|
7
|
+
And the output should contain "ghc team add_repo"
|
8
|
+
And the output should contain "ghc team create"
|
9
|
+
And the output should contain "ghc team delete"
|
10
|
+
And the output should contain "ghc team edit"
|
11
|
+
And the output should contain "ghc team get"
|
12
|
+
And the output should contain "ghc team list"
|
13
|
+
And the output should contain "ghc team list_member"
|
14
|
+
And the output should contain "ghc team list_repo"
|
15
|
+
And the output should contain "ghc team member"
|
16
|
+
And the output should contain "ghc team remove_member"
|
17
|
+
And the output should contain "ghc team remove_repo"
|
18
|
+
And the output should contain "ghc team repo"
|
data/ghc_logo.png
ADDED
Binary file
|
data/github_cli.gemspec
CHANGED
@@ -5,7 +5,7 @@ Gem::Specification.new do |gem|
|
|
5
5
|
gem.authors = ["Piotr Murach"]
|
6
6
|
gem.email = ["pmurach@gmail.com"]
|
7
7
|
gem.description = %q{CLI-based access to GitHub API v3}
|
8
|
-
gem.summary = %q{
|
8
|
+
gem.summary = %q{github_cli is a set of tools that provide full command line access to GitHub API v3}
|
9
9
|
gem.homepage = "http://github.com/peter-murach/github_cli"
|
10
10
|
|
11
11
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
@@ -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.
|
18
|
+
gem.add_dependency 'github_api', '~> 0.6'
|
19
19
|
gem.add_dependency 'thor'
|
20
20
|
|
21
21
|
gem.add_development_dependency 'rspec'
|
data/lib/github_cli/api.rb
CHANGED
@@ -3,27 +3,30 @@
|
|
3
3
|
module GithubCLI
|
4
4
|
# The API class is the main entry point for creating GithubCLI APIs.
|
5
5
|
class API
|
6
|
-
class ApiError < StandardError; end
|
7
6
|
|
8
7
|
@@api = nil
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
class << self
|
10
|
+
|
11
|
+
def github_api
|
12
|
+
@@api ||= begin
|
13
|
+
@@api = configure_api
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def configure_api
|
14
18
|
@@api = Github.new
|
15
19
|
@@api.oauth_token = GithubCLI.config['oauth_token']
|
16
20
|
@@api.basic_auth = GithubCLI.config['basic_auth']
|
17
21
|
@@api
|
18
22
|
end
|
19
|
-
end
|
20
23
|
|
21
|
-
|
22
|
-
|
24
|
+
def output(format=:table, &block)
|
25
|
+
response = block.call
|
26
|
+
formatter = Formatter.new response, :format => format
|
27
|
+
formatter.render_output
|
28
|
+
end
|
23
29
|
|
24
|
-
def self.output(format=:table, &block)
|
25
|
-
response = block.call
|
26
|
-
GithubCLI::Terminal.render_output response, :format => format
|
27
30
|
end
|
28
31
|
|
29
32
|
class All
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module GithubCLI
|
4
|
+
class Follower < API
|
5
|
+
|
6
|
+
class << self
|
7
|
+
|
8
|
+
def all(user, params, format)
|
9
|
+
output format do
|
10
|
+
github_api.users.followers.list user, params
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def following(user, params, format)
|
15
|
+
output format do
|
16
|
+
github_api.users.followers.following user, params
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def follower(user, params, format)
|
21
|
+
output format do
|
22
|
+
github_api.users.followers.following? user, params
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def follow(user, params, format)
|
27
|
+
output format do
|
28
|
+
github_api.users.followers.follow user, params
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def unfollow(user, params, format)
|
33
|
+
output format do
|
34
|
+
github_api.users.followers.unfollow user, params
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end # Follower
|
40
|
+
end # GithubCLI
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module GithubCLI
|
4
|
+
class Member < API
|
5
|
+
|
6
|
+
class << self
|
7
|
+
|
8
|
+
def all(org, params, format)
|
9
|
+
output format do
|
10
|
+
github_api.orgs.members.list org, params
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def all_public(org, params, format)
|
15
|
+
output format do
|
16
|
+
github_api.orgs.members.list_public org, params
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def member?(org, user, params, format)
|
21
|
+
output format do
|
22
|
+
github_api.orgs.members.member? org, user, params
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def public_member?(org, user, params, format)
|
27
|
+
output format do
|
28
|
+
github_api.orgs.members.public_member? org, user, params
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def delete(org, user, params, format)
|
33
|
+
output format do
|
34
|
+
github_api.orgs.members.delete org, user, params
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def publicize(org, user, params, format)
|
39
|
+
output format do
|
40
|
+
github_api.orgs.members.publicize org, user, params
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def conceal(org, user, params, format)
|
45
|
+
output format do
|
46
|
+
github_api.orgs.members.conceal org, user, params
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end # Member
|
52
|
+
end # GithubCLI
|