github_cli 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. data/CHANGELOG.md +9 -0
  2. data/Gemfile.lock +3 -3
  3. data/README.md +30 -0
  4. data/bin/ghc +13 -1
  5. data/features/repositories.feature +9 -0
  6. data/github_cli.gemspec +1 -1
  7. data/lib/github_cli.rb +2 -0
  8. data/lib/github_cli/api.rb +7 -2
  9. data/lib/github_cli/apis.rb +4 -0
  10. data/lib/github_cli/apis/authorization.rb +20 -10
  11. data/lib/github_cli/apis/blob.rb +8 -4
  12. data/lib/github_cli/apis/collaborator.rb +34 -0
  13. data/lib/github_cli/apis/commit.rb +8 -4
  14. data/lib/github_cli/apis/download.rb +20 -10
  15. data/lib/github_cli/apis/fork.rb +8 -4
  16. data/lib/github_cli/apis/gist.rb +70 -0
  17. data/lib/github_cli/apis/hook.rb +24 -12
  18. data/lib/github_cli/apis/issue.rb +40 -0
  19. data/lib/github_cli/apis/key.rb +20 -10
  20. data/lib/github_cli/apis/label.rb +40 -18
  21. data/lib/github_cli/apis/pull_request.rb +32 -16
  22. data/lib/github_cli/apis/reference.rb +20 -10
  23. data/lib/github_cli/apis/repository.rb +36 -19
  24. data/lib/github_cli/apis/tag.rb +8 -4
  25. data/lib/github_cli/apis/tree.rb +8 -4
  26. data/lib/github_cli/apis/watching.rb +20 -10
  27. data/lib/github_cli/command.rb +19 -0
  28. data/lib/github_cli/commands.rb +2 -0
  29. data/lib/github_cli/commands/authorizations.rb +5 -5
  30. data/lib/github_cli/commands/blobs.rb +2 -2
  31. data/lib/github_cli/commands/collaborators.rb +37 -0
  32. data/lib/github_cli/commands/commits.rb +2 -2
  33. data/lib/github_cli/commands/downloads.rb +5 -5
  34. data/lib/github_cli/commands/forks.rb +2 -2
  35. data/lib/github_cli/commands/gists.rb +103 -0
  36. data/lib/github_cli/commands/hooks.rb +6 -6
  37. data/lib/github_cli/commands/issues.rb +67 -18
  38. data/lib/github_cli/commands/keys.rb +5 -5
  39. data/lib/github_cli/commands/labels.rb +8 -8
  40. data/lib/github_cli/commands/pull_requests.rb +8 -8
  41. data/lib/github_cli/commands/references.rb +5 -5
  42. data/lib/github_cli/commands/repositories.rb +20 -20
  43. data/lib/github_cli/commands/tags.rb +2 -2
  44. data/lib/github_cli/commands/trees.rb +2 -2
  45. data/lib/github_cli/commands/watching.rb +5 -5
  46. data/lib/github_cli/errors.rb +33 -2
  47. data/lib/github_cli/formatters.rb +8 -0
  48. data/lib/github_cli/formatters/csv.rb +39 -0
  49. data/lib/github_cli/formatters/table.rb +36 -0
  50. data/lib/github_cli/subcommands.rb +6 -0
  51. data/lib/github_cli/terminal.rb +25 -0
  52. data/lib/github_cli/util.rb +35 -0
  53. data/lib/github_cli/version.rb +1 -1
  54. data/spec/github_cli/util_spec.rb +37 -0
  55. metadata +26 -13
@@ -0,0 +1,40 @@
1
+ # encoding: utf-8
2
+
3
+ module GithubCLI
4
+ class Issue < API
5
+
6
+ class << self
7
+
8
+ def all(params, format)
9
+ output format do
10
+ github_api.issues.list params
11
+ end
12
+ end
13
+
14
+ def all_repo(user, repo, params, format)
15
+ output format do
16
+ github_api.issues.list_repo user, reop, params
17
+ end
18
+ end
19
+
20
+ def get(user, repo, id, params, format)
21
+ output format do
22
+ github_api.issues.get user, repo, id, params
23
+ end
24
+ end
25
+
26
+ def create(user, repo, params, format)
27
+ output format do
28
+ github_api.issues.create user, repo, params
29
+ end
30
+ end
31
+
32
+ def edit(user, repo, id, params, format)
33
+ output format do
34
+ github_api.issues.edit user, repo, id, params
35
+ end
36
+ end
37
+ end
38
+
39
+ end # Issue
40
+ end # GithubCLI
@@ -5,24 +5,34 @@ module GithubCLI
5
5
 
6
6
  class << self
7
7
 
8
- def all(user, repo, params)
9
- github_api.repos.keys.list user, repo, params
8
+ def all(user, repo, params, format)
9
+ output format do
10
+ github_api.repos.keys.list user, repo, params
11
+ end
10
12
  end
11
13
 
12
- def get(user, repo, id, params)
13
- github_api.repos.keys.get user, repo, id, params
14
+ def get(user, repo, id, params, format)
15
+ output format do
16
+ github_api.repos.keys.get user, repo, id, params
17
+ end
14
18
  end
15
19
 
16
- def create(user, repo, params)
17
- github_api.repos.keys.create user, repo, params
20
+ def create(user, repo, params, format)
21
+ output format do
22
+ github_api.repos.keys.create user, repo, params
23
+ end
18
24
  end
19
25
 
20
- def edit(user, repo, id, params)
21
- github_api.repos.keys.edit user, repo, id, params
26
+ def edit(user, repo, id, params, format)
27
+ output format do
28
+ github_api.repos.keys.edit user, repo, id, params
29
+ end
22
30
  end
23
31
 
24
- def delete(user, repo, id, params)
25
- github_api.repos.keys.delete user, repo, id, params
32
+ def delete(user, repo, id, params, format)
33
+ output format do
34
+ github_api.repos.keys.delete user, repo, id, params
35
+ end
26
36
  end
27
37
  end
28
38
 
@@ -5,44 +5,66 @@ module GithubCLI
5
5
 
6
6
  class << self
7
7
 
8
- def all(params)
9
- github_api.issues.labels params
8
+ def all(params, format)
9
+ output format do
10
+ github_api.issues.labels params
11
+ end
10
12
  end
11
13
 
12
- def get(user, repo, name, params)
13
- github_api.issues.get_label user, repo, name, params
14
+ def get(user, repo, name, params, format)
15
+ output format do
16
+ github_api.issues.get_label user, repo, name, params
17
+ end
14
18
  end
15
19
 
16
- def create(user, repo, params)
17
- github_api.issues.create_label user, repo, params
20
+ def create(user, repo, params, format)
21
+ output format do
22
+ github_api.issues.create_label user, repo, params
23
+ end
18
24
  end
19
25
 
20
- def update(user, repo, name, params)
21
- github_api.issues.update_label user, repo, params
26
+ def update(user, repo, name, params, format)
27
+ output format do
28
+ github_api.issues.update_label user, repo, params
29
+ end
22
30
  end
23
31
 
24
- def delete(user, repo, name, params)
25
- github_api.issues.delete_label user, repo, name, params
32
+ def delete(user, repo, name, params, format)
33
+ output format do
34
+ github_api.issues.delete_label user, repo, name, params
35
+ end
26
36
  end
27
37
 
28
- def issue(user, repo, number, params)
29
- github_api.issues.labels_for user, repo, number, params
38
+ def issue(user, repo, number, params, format)
39
+ output format do
40
+ github_api.issues.labels_for user, repo, number, params
41
+ end
30
42
  end
31
43
 
32
44
  def add(user, repo, number, *args)
33
- github_api.issues.add_labels user, repo, args
45
+ # TODO extract params from args
46
+ output :table do
47
+ github_api.issues.add_labels user, repo, args
48
+ end
34
49
  end
35
50
 
36
- def remove(user, repo, number, name=nil, params)
37
- github_api.issues.remove_label user, repo, number, name, params
51
+ def remove(user, repo, number, name=nil, params, format)
52
+ output format do
53
+ github_api.issues.remove_label user, repo, number, name, params
54
+ end
38
55
  end
39
56
 
40
57
  def replace(user, repo, number, *args)
41
- github_api.issues.replace_labels user, repo, number, args
58
+ # TODO extract params from args
59
+ output :table do
60
+ github_api.issues.replace_labels user, repo, number, args
61
+ end
42
62
  end
43
63
 
44
- def milestone(user, repo, number, params)
45
- gitub_api.issues.milestone_labels user, repo, number, params
64
+ def milestone(user, repo, number, params, format)
65
+ output format do
66
+ gitub_api.issues.milestone_labels user, repo, number, params
67
+ end
46
68
  end
47
69
  end
48
70
 
@@ -5,36 +5,52 @@ module GithubCLI
5
5
 
6
6
  class << self
7
7
 
8
- def get(user, repo, number, params)
9
- github_api.pull_requests.pull_request user, repo, number, params
8
+ def get(user, repo, number, params, format)
9
+ output format do
10
+ github_api.pull_requests.pull_request user, repo, number, params
11
+ end
10
12
  end
11
13
 
12
- def list(user, repo, ref, params)
13
- github_api.pull_requests.pull_requests user, repo, ref, params
14
+ def list(user, repo, ref, params, format)
15
+ output format do
16
+ github_api.pull_requests.pull_requests user, repo, ref, params
17
+ end
14
18
  end
15
19
 
16
- def create(user, repo, params)
17
- github_api.pull_requests.create_request user, repo, params
20
+ def create(user, repo, params, format)
21
+ output format do
22
+ github_api.pull_requests.create_request user, repo, params
23
+ end
18
24
  end
19
25
 
20
- def update(user, repo, number, params)
21
- github_api.pull_requests.update_request user, repo, number, params
26
+ def update(user, repo, number, params, format)
27
+ output format do
28
+ github_api.pull_requests.update_request user, repo, number, params
29
+ end
22
30
  end
23
31
 
24
- def commits(user, repo, number, params)
25
- github_api.pull_requests.commits user, repo, number, params
32
+ def commits(user, repo, number, params, format)
33
+ output format do
34
+ github_api.pull_requests.commits user, repo, number, params
35
+ end
26
36
  end
27
37
 
28
- def files(user, repo, number, params)
29
- github_api.pull_requests.files user, repo, number, params
38
+ def files(user, repo, number, params, format)
39
+ output format do
40
+ github_api.pull_requests.files user, repo, number, params
41
+ end
30
42
  end
31
43
 
32
- def merged(user, repo, number, params)
33
- github_api.pull_requests.merged user, repo, number, params
44
+ def merged(user, repo, number, params, format)
45
+ output format do
46
+ github_api.pull_requests.merged user, repo, number, params
47
+ end
34
48
  end
35
49
 
36
- def merge(user, repo, number, params)
37
- github_api.pull_requests.merge user, repo, number, params
50
+ def merge(user, repo, number, params, format)
51
+ output format do
52
+ github_api.pull_requests.merge user, repo, number, params
53
+ end
38
54
  end
39
55
  end
40
56
 
@@ -5,24 +5,34 @@ module GithubCLI
5
5
 
6
6
  class << self
7
7
 
8
- def list(user, repo, ref, params)
9
- github_api.git_data.references.list user, repo, ref, params
8
+ def list(user, repo, ref, params, format)
9
+ output format do
10
+ github_api.git_data.references.list user, repo, ref, params
11
+ end
10
12
  end
11
13
 
12
- def get(user, repo, ref, params)
13
- github_api.git_data.references.get user, repo, ref, params
14
+ def get(user, repo, ref, params, format)
15
+ output format do
16
+ github_api.git_data.references.get user, repo, ref, params
17
+ end
14
18
  end
15
19
 
16
- def create(user, repo, params)
17
- github_api.git_data.references.create user, repo, params
20
+ def create(user, repo, params, format)
21
+ output format do
22
+ github_api.git_data.references.create user, repo, params
23
+ end
18
24
  end
19
25
 
20
- def update(user, repo, ref, params)
21
- github_api.git_data.references.update user, repo, ref, params
26
+ def update(user, repo, ref, params, format)
27
+ output format do
28
+ github_api.git_data.references.update user, repo, ref, params
29
+ end
22
30
  end
23
31
 
24
- def delete(user, repo, ref, params)
25
- github_api.git_data.references.delete user, repo, ref, params
32
+ def delete(user, repo, ref, params, format)
33
+ output format do
34
+ github_api.git_data.references.delete user, repo, ref, params
35
+ end
26
36
  end
27
37
  end
28
38
 
@@ -5,42 +5,59 @@ module GithubCLI
5
5
 
6
6
  class << self
7
7
 
8
- def all(params)
9
- github_api.repos.list params
8
+ def all(params, format)
9
+ output format do
10
+ github_api.repos.list params
11
+ end
10
12
  end
11
13
 
12
- def get(user, repo, params)
13
- github_api.repos.get user, repo, params
14
+ def get(user, repo, params, format)
15
+ output format do
16
+ github_api.repos.get user, repo, params
17
+ end
14
18
  end
15
19
 
16
- def create(params)
17
- github_api.repos.create params
20
+ def create(params, format)
21
+ output format do
22
+ github_api.repos.create params
23
+ end
18
24
  end
19
25
 
20
- def edit(user, repo, params)
21
- github_api.repos.edit user, repo, params
26
+ def edit(user, repo, params, format)
27
+ output format do
28
+ github_api.repos.edit user, repo, params
29
+ end
22
30
  end
23
31
 
24
- def branches(user, repo, params)
25
- github_api.repos.branches user, repo, params
32
+ def branches(user, repo, params, format)
33
+ output format do
34
+ github_api.repos.branches user, repo, params
35
+ end
26
36
  end
27
37
 
28
- def contributors(user, repo, params)
29
- github_api.repos.contributors user, repo, params
38
+ def contributors(user, repo, params, format)
39
+ output format do
40
+ github_api.repos.contributors user, repo, params
41
+ end
30
42
  end
31
43
 
32
- def languages(user, repo, params)
33
- github_api.repos.languages user, repo, params
44
+ def languages(user, repo, params, format)
45
+ output format do
46
+ github_api.repos.languages user, repo, params
47
+ end
34
48
  end
35
49
 
36
- def tags(user, repo, params)
37
- github_api.repos.tags user, repo, params
50
+ def tags(user, repo, params, format)
51
+ output format do
52
+ github_api.repos.tags user, repo, params
53
+ end
38
54
  end
39
55
 
40
- def teams(user, repo, params)
41
- github_api.repos.teams user, repo, params
56
+ def teams(user, repo, params, format)
57
+ output format do
58
+ github_api.repos.teams user, repo, params
59
+ end
42
60
  end
43
-
44
61
  end
45
62
 
46
63
  end # Repository
@@ -5,12 +5,16 @@ module GithubCLI
5
5
 
6
6
  class << self
7
7
 
8
- def get(user, repo, sha, params)
9
- github_api.git_data.tags.get user, repo, params
8
+ def get(user, repo, sha, params, format)
9
+ output format do
10
+ github_api.git_data.tags.get user, repo, params
11
+ end
10
12
  end
11
13
 
12
- def create(user, repo, params)
13
- github_api.git_data.tags.create user, repo, params
14
+ def create(user, repo, params, format)
15
+ output format do
16
+ github_api.git_data.tags.create user, repo, params
17
+ end
14
18
  end
15
19
  end
16
20
 
@@ -5,12 +5,16 @@ module GithubCLI
5
5
 
6
6
  class << self
7
7
 
8
- def get(user, repo, sha, params)
9
- github_api.git_data.trees.get user, repo, sha, params
8
+ def get(user, repo, sha, params, format)
9
+ output format do
10
+ github_api.git_data.trees.get user, repo, sha, params
11
+ end
10
12
  end
11
13
 
12
- def create(user, repo, params)
13
- github_api.git_data.trees.create user, repo, params
14
+ def create(user, repo, params, format)
15
+ output format do
16
+ github_api.git_data.trees.create user, repo, params
17
+ end
14
18
  end
15
19
  end
16
20
 
@@ -5,24 +5,34 @@ module GithubCLI
5
5
 
6
6
  class << self
7
7
 
8
- def watchers(user, repo, params)
9
- github_api.repos.watching.watchers user, repo, params
8
+ def watchers(user, repo, params, format)
9
+ output format do
10
+ github_api.repos.watching.watchers user, repo, params
11
+ end
10
12
  end
11
13
 
12
- def watched(params)
13
- github_api.repos.watching.watched user, repo, id, params
14
+ def watched(params, format)
15
+ output format do
16
+ github_api.repos.watching.watched user, repo, id, params
17
+ end
14
18
  end
15
19
 
16
- def watching?(user, repo, params)
17
- github_api.repos.watching.watching? user, repo, params
20
+ def watching?(user, repo, params, format)
21
+ output format do
22
+ github_api.repos.watching.watching? user, repo, params
23
+ end
18
24
  end
19
25
 
20
- def start_watching(user, repo, params)
21
- github_api.repos.watching.start_watching user, repo, params
26
+ def start_watching(user, repo, params, format)
27
+ output format do
28
+ github_api.repos.watching.start_watching user, repo, params
29
+ end
22
30
  end
23
31
 
24
- def stop_watching(user, repo, params)
25
- github_api.repos.watching.stop_watching user, repo, params
32
+ def stop_watching(user, repo, params, format)
33
+ output format do
34
+ github_api.repos.watching.stop_watching user, repo, params
35
+ end
26
36
  end
27
37
  end
28
38