github_cli 0.5.6 → 0.5.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +1 -1
- data/features/hook.feature +8 -7
- data/features/notification.feature +33 -0
- data/lib/github_cli/api.rb +9 -7
- data/lib/github_cli/apis/notification.rb +22 -0
- data/lib/github_cli/apis.rb +3 -34
- data/lib/github_cli/cli.rb +3 -3
- data/lib/github_cli/command.rb +9 -0
- data/lib/github_cli/commands/hooks.rb +37 -3
- data/lib/github_cli/commands/notifications.rb +38 -0
- data/lib/github_cli/commands.rb +1 -0
- data/lib/github_cli/dsl.rb +8 -1
- data/lib/github_cli/formatter.rb +14 -4
- data/lib/github_cli/subcommands.rb +34 -31
- data/lib/github_cli/thor_ext.rb +2 -6
- data/lib/github_cli/version.rb +1 -1
- data/lib/github_cli.rb +4 -0
- data/spec/github_cli/commands/hooks_spec.rb +45 -0
- data/spec/github_cli/commands/notifications_spec.rb +26 -0
- metadata +22 -14
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
0.5.7 (April 4, 2013)
|
2
|
+
|
3
|
+
* Change apis.rb to dynamically load api files
|
4
|
+
* Change interface to remove command options and clean up descriptions
|
5
|
+
* Add notify command for Notifications API access
|
6
|
+
* Change error handling for output to provided common error type
|
7
|
+
* Change hooks commands to take specific options and add tests
|
8
|
+
* Fix error on empty response bodies
|
9
|
+
|
1
10
|
0.5.6 (April 1, 2013)
|
2
11
|
|
3
12
|
* Change gcli interface to be more concise and not include gcli name
|
data/Gemfile.lock
CHANGED
data/features/hook.feature
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
Feature: gcli hook
|
2
2
|
|
3
|
+
@ci-run
|
3
4
|
Scenario: Available commands
|
4
5
|
|
5
6
|
When I run `gcli hook`
|
6
7
|
Then the exit status should be 0
|
7
|
-
And the output should contain "
|
8
|
-
And the output should contain "
|
9
|
-
And the output should contain "
|
10
|
-
And the output should contain "
|
11
|
-
And the output should contain "
|
12
|
-
And the output should contain "
|
8
|
+
And the output should contain "hook create"
|
9
|
+
And the output should contain "hook delete"
|
10
|
+
And the output should contain "hook edit"
|
11
|
+
And the output should contain "hook get"
|
12
|
+
And the output should contain "hook list"
|
13
|
+
And the output should contain "hook test"
|
13
14
|
|
14
15
|
Scenario: List hooks
|
15
16
|
Given the GitHub API server:
|
@@ -32,7 +33,7 @@ Feature: gcli hook
|
|
32
33
|
"""
|
33
34
|
post('/repos/wycats/thor/hooks') { status 200 }
|
34
35
|
"""
|
35
|
-
When I run `gcli hook create wycats thor --
|
36
|
+
When I run `gcli hook create wycats thor --name=web --config="url:http://example.com/webhook" --events=status`
|
36
37
|
Then the exit status should be 0
|
37
38
|
|
38
39
|
Scenario: Edit hook
|
@@ -0,0 +1,33 @@
|
|
1
|
+
Feature: gcli notify
|
2
|
+
|
3
|
+
@ci-run
|
4
|
+
Scenario: Available commands
|
5
|
+
|
6
|
+
When I run `gcli notify`
|
7
|
+
Then the exit status should be 0
|
8
|
+
And the output should contain "notify list"
|
9
|
+
And the output should contain "notify get"
|
10
|
+
|
11
|
+
Scenario: List notifications
|
12
|
+
Given the GitHub API server:
|
13
|
+
"""
|
14
|
+
get('/notifications') { status 200 }
|
15
|
+
"""
|
16
|
+
When I successfully run `gcli notify ls`
|
17
|
+
Then the exit status should be 0
|
18
|
+
|
19
|
+
Scenario: List repo notifications
|
20
|
+
Given the GitHub API server:
|
21
|
+
"""
|
22
|
+
get('/repos/wycats/thor/notifications') { status 200 }
|
23
|
+
"""
|
24
|
+
When I successfully run `gcli notify ls -u wycats -r thor`
|
25
|
+
Then the exit status should be 0
|
26
|
+
|
27
|
+
Scenario: View thread
|
28
|
+
Given the GitHub API server:
|
29
|
+
"""
|
30
|
+
get('/notifications/threads/1') { status 200 }
|
31
|
+
"""
|
32
|
+
When I run `gcli notify get 1`
|
33
|
+
Then the exit status should be 0
|
data/lib/github_cli/api.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module GithubCLI
|
4
4
|
|
5
5
|
# The API class is the main entry point for creating GithubCLI APIs.
|
6
|
-
class API
|
6
|
+
class API
|
7
7
|
|
8
8
|
@@api = nil
|
9
9
|
|
@@ -39,12 +39,14 @@ module GithubCLI
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def output(format=:table, &block)
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
42
|
+
GithubCLI.on_error do
|
43
|
+
response = block.call
|
44
|
+
if response.respond_to?(:body)
|
45
|
+
formatter = Formatter.new response, :format => format
|
46
|
+
formatter.render_output
|
47
|
+
else
|
48
|
+
response
|
49
|
+
end
|
48
50
|
end
|
49
51
|
end
|
50
52
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module GithubCLI
|
4
|
+
class Notification < API
|
5
|
+
|
6
|
+
class << self
|
7
|
+
|
8
|
+
def all(params, format)
|
9
|
+
output format do
|
10
|
+
github_api.activity.notifications.list params
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def get(id, params, format)
|
15
|
+
output format do
|
16
|
+
github_api.activity.notifications.get id, params
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end # Notification
|
22
|
+
end # GithubCLI
|
data/lib/github_cli/apis.rb
CHANGED
@@ -8,38 +8,7 @@ else
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
blob
|
15
|
-
collaborator
|
16
|
-
commit
|
17
|
-
content
|
18
|
-
download
|
19
|
-
email
|
20
|
-
event
|
21
|
-
follower
|
22
|
-
fork
|
23
|
-
gist
|
24
|
-
hook
|
25
|
-
issue
|
26
|
-
key
|
27
|
-
label
|
28
|
-
member
|
29
|
-
merging
|
30
|
-
milestone
|
31
|
-
organization
|
32
|
-
pull_request
|
33
|
-
reference
|
34
|
-
repository
|
35
|
-
search
|
36
|
-
starring
|
37
|
-
status
|
38
|
-
tag
|
39
|
-
team
|
40
|
-
tree
|
41
|
-
user
|
42
|
-
watching
|
43
|
-
].each do |api|
|
44
|
-
require_api api
|
11
|
+
Dir[File.dirname(__FILE__) + '/apis/*.rb'].sort.each do |path|
|
12
|
+
filename = File.basename(path)
|
13
|
+
require_api(filename)
|
45
14
|
end
|
data/lib/github_cli/cli.rb
CHANGED
@@ -68,7 +68,7 @@ module GithubCLI
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
desc 'init
|
71
|
+
desc 'init', 'Create a configuration file or overwirte existing one'
|
72
72
|
long_desc <<-DESC
|
73
73
|
Initializes a configuration file where you can set default options for
|
74
74
|
interacting with GitHub API.\n
|
@@ -95,7 +95,7 @@ module GithubCLI
|
|
95
95
|
GithubCLI.ui.confirm "Writing new configuration file to #{GithubCLI.config.path}"
|
96
96
|
end
|
97
97
|
|
98
|
-
desc 'config
|
98
|
+
desc 'config', 'Get and set GitHub configuration options'
|
99
99
|
long_desc <<-DESC
|
100
100
|
You can query/set options with this command. The name is actually a hash key
|
101
101
|
string that is a composite one, nested with dots. If only name is provided, a
|
@@ -140,7 +140,7 @@ module GithubCLI
|
|
140
140
|
return
|
141
141
|
end
|
142
142
|
|
143
|
-
desc 'list
|
143
|
+
desc 'list', 'List all available commands limited by pattern'
|
144
144
|
def list(pattern="")
|
145
145
|
pattern = /^#{pattern}.*$/i
|
146
146
|
Terminal.print_commands pattern
|
data/lib/github_cli/command.rb
CHANGED
@@ -49,6 +49,15 @@ module GithubCLI
|
|
49
49
|
|
50
50
|
class << self
|
51
51
|
|
52
|
+
def api(name=nil)
|
53
|
+
@api = case name
|
54
|
+
when nil
|
55
|
+
@api || GithubCLI.const_get(name.to_s.capitalize)
|
56
|
+
else
|
57
|
+
@pi
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
52
61
|
def banner(task, namespace=true, subcommand=true)
|
53
62
|
"#{basename} #{task.formatted_usage(self, true, subcommand)}"
|
54
63
|
end
|
@@ -5,7 +5,7 @@ module GithubCLI
|
|
5
5
|
|
6
6
|
namespace :hook
|
7
7
|
|
8
|
-
desc 'list <user> <repo>', '
|
8
|
+
desc 'list <user> <repo>', 'List repository hooks'
|
9
9
|
def list(user, repo)
|
10
10
|
Hook.all user, repo, options[:params], options[:format]
|
11
11
|
end
|
@@ -15,6 +15,14 @@ module GithubCLI
|
|
15
15
|
Hook.get user, repo, id, options[:params], options[:format]
|
16
16
|
end
|
17
17
|
|
18
|
+
option :name, :type => :string, :required => true, :banner => "service",
|
19
|
+
:desc => "the name of the service that is being called"
|
20
|
+
option :config, :type => :hash, :required => :true, :banner => "",
|
21
|
+
:desc => "a hash containing key/value pairs to provide settings for this hook"
|
22
|
+
option :events, :type => :array,
|
23
|
+
:desc => "Determines what events the hook is triggered for. Default: ['push']"
|
24
|
+
option :active, :type => :boolean, :default => true,
|
25
|
+
:desc => "determines whether the hook is actually triggered on pushes"
|
18
26
|
desc 'create <user> <repo>', 'Create a hook'
|
19
27
|
long_desc <<-DESC
|
20
28
|
Inputs
|
@@ -25,9 +33,27 @@ module GithubCLI
|
|
25
33
|
active - Optional boolean - Determines whether the hook is actually triggered on pushes.
|
26
34
|
DESC
|
27
35
|
def create(user, repo)
|
28
|
-
|
36
|
+
params = options[:params].dup
|
37
|
+
params['name'] = options[:name]
|
38
|
+
params['config'] = options[:config]
|
39
|
+
params['events'] = options[:events] if options[:events]
|
40
|
+
params['active'] = options[:active] if options[:active]
|
41
|
+
|
42
|
+
Hook.create user, repo, params, options[:format]
|
29
43
|
end
|
30
44
|
|
45
|
+
option :name, :type => :string, :required => true, :banner => "service",
|
46
|
+
:desc => "the name of the service that is being called"
|
47
|
+
option :config, :type => :hash, :required => :true, :banner => "",
|
48
|
+
:desc => "a hash containing key/value pairs to provide settings for this hook"
|
49
|
+
option :events, :type => :array,
|
50
|
+
:desc => "Determines what events the hook is triggered for. Default: ['push']"
|
51
|
+
option :add_events, :type => :array,
|
52
|
+
:desc => "Determines a list of events to be added to the list of events that the Hook triggers for."
|
53
|
+
option :remove_events, :type => :array,
|
54
|
+
:desc => "Determines a list of events to be removed from the list of events that the Hook triggers for."
|
55
|
+
option :active, :type => :boolean, :default => true,
|
56
|
+
:desc => "determines whether the hook is actually triggered on pushes"
|
31
57
|
desc 'edit <user> <repo> <id>', 'Edit a hook'
|
32
58
|
long_desc <<-DESC
|
33
59
|
Inputs
|
@@ -40,7 +66,15 @@ module GithubCLI
|
|
40
66
|
active - Optional boolean - Determines whether the hook is actually triggered on pushes. \n
|
41
67
|
DESC
|
42
68
|
def edit(user, repo, id)
|
43
|
-
|
69
|
+
params = options[:params].dup
|
70
|
+
params['name'] = options[:name]
|
71
|
+
params['config'] = options[:config]
|
72
|
+
params['events'] = options[:events] if options[:events]
|
73
|
+
params['add_events'] = options[:add_events] if options[:add_events]
|
74
|
+
params['remove_events'] = options[:remove_events] if options[:remove_events]
|
75
|
+
params['active'] = options[:active] if options[:active]
|
76
|
+
|
77
|
+
Hook.edit user, repo, id, params, options[:format]
|
44
78
|
end
|
45
79
|
|
46
80
|
desc 'test <user> <repo> <id>', 'Test a hook'
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module GithubCLI
|
4
|
+
class Commands::Notifications < Command
|
5
|
+
|
6
|
+
namespace :notify
|
7
|
+
|
8
|
+
option :all, :type => :boolean,
|
9
|
+
:desc => "true to show notifications marked as read."
|
10
|
+
option :participating, :type => :boolean,
|
11
|
+
:desc => "true to show only notifications in which the user is directly participating or mentioned."
|
12
|
+
option :since, :type => :string,
|
13
|
+
:desc => "filters out any notifications updated before the given time"
|
14
|
+
option :user, :type => :string, :aliases => ["-u"]
|
15
|
+
option :repo, :type => :string, :aliases => ["-r"]
|
16
|
+
desc 'list', 'List your notifications'
|
17
|
+
long_desc <<-DESC
|
18
|
+
Parameters
|
19
|
+
|
20
|
+
all - Optional boolean - true to show notifications marked as read.\n
|
21
|
+
participating - Optional boolean - true to show only notifications in which the user is directly participating or mentioned.\n
|
22
|
+
since - Optional time - filters out any notifications updated before the given time.\n
|
23
|
+
DESC
|
24
|
+
def list
|
25
|
+
params = options[:params].dup
|
26
|
+
params['user'] = options[:user] if options[:user]
|
27
|
+
params['repo'] = options[:repo] if options[:repo]
|
28
|
+
|
29
|
+
Notification.all params, options[:format]
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'get <id>', 'View a single thread'
|
33
|
+
def get(id)
|
34
|
+
Notification.get id, options[:params], options[:format]
|
35
|
+
end
|
36
|
+
|
37
|
+
end # Notifications
|
38
|
+
end # GithubCLI
|
data/lib/github_cli/commands.rb
CHANGED
@@ -21,6 +21,7 @@ module GithubCLI
|
|
21
21
|
autoload :Members, 'github_cli/commands/members'
|
22
22
|
autoload :Merging, 'github_cli/commands/merging'
|
23
23
|
autoload :Milestones, 'github_cli/commands/milestones'
|
24
|
+
autoload :Notifications, 'github_cli/commands/notifications'
|
24
25
|
autoload :Organizations, 'github_cli/commands/organizations'
|
25
26
|
autoload :PullRequests, 'github_cli/commands/pull_requests'
|
26
27
|
autoload :References, 'github_cli/commands/references'
|
data/lib/github_cli/dsl.rb
CHANGED
@@ -19,7 +19,14 @@ module GithubCLI
|
|
19
19
|
def on_error
|
20
20
|
yield
|
21
21
|
rescue Exception => error
|
22
|
-
|
22
|
+
case error
|
23
|
+
when Github::Error::NotFound
|
24
|
+
terminal.newline
|
25
|
+
ui.error 'Resource Not Found'
|
26
|
+
terminal.newline
|
27
|
+
else
|
28
|
+
raise GithubCLI::GithubCLIError, "Rescued: #{error}"
|
29
|
+
end
|
23
30
|
end
|
24
31
|
|
25
32
|
def before(&block)
|
data/lib/github_cli/formatter.rb
CHANGED
@@ -5,10 +5,11 @@ module GithubCLI
|
|
5
5
|
# It delegates to other objects like Formatter::Table
|
6
6
|
# to perform actual rendering.
|
7
7
|
class Formatter
|
8
|
-
attr_reader :response, :format
|
8
|
+
attr_reader :response, :format, :message
|
9
9
|
|
10
10
|
def initialize(response, options={})
|
11
11
|
@response = response
|
12
|
+
@message = options[:message]
|
12
13
|
@format = options[:format]
|
13
14
|
end
|
14
15
|
|
@@ -16,14 +17,17 @@ module GithubCLI
|
|
16
17
|
render_status
|
17
18
|
Terminal.paged_output
|
18
19
|
determine_output_formatter
|
20
|
+
render_message
|
19
21
|
end
|
20
22
|
|
21
23
|
def determine_output_formatter
|
22
24
|
case format.to_s
|
23
25
|
when 'table', /table:v.*/, /table:h.*/
|
24
|
-
|
25
|
-
|
26
|
-
|
26
|
+
if response.body && !response.body.empty?
|
27
|
+
formatter = Formatters::Table.new(response.body,
|
28
|
+
:transform => format.to_s.split(':').last)
|
29
|
+
formatter.format
|
30
|
+
end
|
27
31
|
when 'csv'
|
28
32
|
formatter = Formatters::CSV.new(response)
|
29
33
|
formatter.format
|
@@ -42,5 +46,11 @@ module GithubCLI
|
|
42
46
|
end
|
43
47
|
end
|
44
48
|
|
49
|
+
def render_message
|
50
|
+
if message
|
51
|
+
Terminal.line message
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
45
55
|
end # Formatter
|
46
56
|
end # GithubCLi
|
@@ -3,97 +3,100 @@
|
|
3
3
|
module GithubCLI
|
4
4
|
class CLI
|
5
5
|
|
6
|
-
desc "assignee
|
6
|
+
desc "assignee", "Leverage Assignees API"
|
7
7
|
subcommand "assignee", GithubCLI::Commands::Assignees
|
8
8
|
|
9
|
-
desc "auth
|
9
|
+
desc "auth", "Leverage Authorizations API"
|
10
10
|
subcommand "auth", GithubCLI::Commands::Authorizations
|
11
11
|
|
12
|
-
desc "blob
|
12
|
+
desc "blob", "Leverage Blobs API"
|
13
13
|
subcommand "blob", GithubCLI::Commands::Blobs
|
14
14
|
|
15
|
-
desc "collab
|
15
|
+
desc "collab", "Leverage Collaborators API"
|
16
16
|
subcommand "collab", GithubCLI::Commands::Collaborators
|
17
17
|
|
18
|
-
desc "commit
|
18
|
+
desc "commit", "Leverage Commits API"
|
19
19
|
subcommand "commit", GithubCLI::Commands::Commits
|
20
20
|
|
21
|
-
desc "content
|
21
|
+
desc "content", "Leverage Contents API"
|
22
22
|
subcommand "content", GithubCLI::Commands::Contents
|
23
23
|
|
24
|
-
desc "download
|
24
|
+
desc "download", "Leverage Downloads API"
|
25
25
|
subcommand "download", GithubCLI::Commands::Downloads
|
26
26
|
|
27
|
-
desc "email
|
27
|
+
desc "email", "Leverage Emails API"
|
28
28
|
subcommand "email", GithubCLI::Commands::Emails
|
29
29
|
|
30
|
-
desc "event
|
30
|
+
desc "event", "Leverage Events API"
|
31
31
|
subcommand "event", GithubCLI::Commands::Events
|
32
32
|
|
33
|
-
desc "follower
|
33
|
+
desc "follower", "Leverage Followers API"
|
34
34
|
subcommand "follower", GithubCLI::Commands::Followers
|
35
35
|
|
36
|
-
desc "fork
|
36
|
+
desc "fork", "Leverage Forks API"
|
37
37
|
subcommand "fork", GithubCLI::Commands::Forks
|
38
38
|
|
39
|
-
desc "gist
|
39
|
+
desc "gist", "Leverage Gists API"
|
40
40
|
subcommand "gist", GithubCLI::Commands::Gists
|
41
41
|
|
42
|
-
desc "hook
|
42
|
+
desc "hook", "Leverage Hooks API"
|
43
43
|
subcommand "hook", GithubCLI::Commands::Hooks
|
44
44
|
|
45
|
-
desc "issue
|
45
|
+
desc "issue", "Leverage Issues API"
|
46
46
|
subcommand "issue", GithubCLI::Commands::Issues
|
47
47
|
|
48
|
-
desc "key
|
48
|
+
desc "key", "Leverage Keys API"
|
49
49
|
subcommand "key", GithubCLI::Commands::Keys
|
50
50
|
|
51
|
-
desc "label
|
51
|
+
desc "label", "Leverage Labels API"
|
52
52
|
subcommand "label", GithubCLI::Commands::Labels
|
53
53
|
|
54
|
-
desc "member
|
54
|
+
desc "member", "Leverage Members API"
|
55
55
|
subcommand "member", GithubCLI::Commands::Members
|
56
56
|
|
57
|
-
desc "merge
|
57
|
+
desc "merge", "Leverage Merging API"
|
58
58
|
subcommand "merge", GithubCLI::Commands::Merging
|
59
59
|
|
60
|
-
desc "milestone
|
60
|
+
desc "milestone", "Leverage Milestones API"
|
61
61
|
subcommand "milestone", GithubCLI::Commands::Milestones
|
62
62
|
|
63
|
-
desc "
|
63
|
+
desc "notify", "Leverage Notifications API"
|
64
|
+
subcommand "notify", GithubCLI::Commands::Notifications
|
65
|
+
|
66
|
+
desc "org", "Leverage Organizations API"
|
64
67
|
subcommand "org", GithubCLI::Commands::Organizations
|
65
68
|
|
66
|
-
desc "pull
|
69
|
+
desc "pull", "Leverage Pull Requests API"
|
67
70
|
subcommand "pull", GithubCLI::Commands::PullRequests
|
68
71
|
|
69
|
-
desc "ref
|
72
|
+
desc "ref", "Leverage References API"
|
70
73
|
subcommand "ref", GithubCLI::Commands::References
|
71
74
|
|
72
|
-
desc "repo
|
75
|
+
desc "repo", "Leverage Repositories API"
|
73
76
|
subcommand "repo", GithubCLI::Commands::Repositories
|
74
77
|
|
75
|
-
desc "search
|
78
|
+
desc "search", "Leverage Search API"
|
76
79
|
subcommand "search", GithubCLI::Commands::Search
|
77
80
|
|
78
|
-
desc "star
|
81
|
+
desc "star", "Leverage Starring API"
|
79
82
|
subcommand "star", GithubCLI::Commands::Starring
|
80
83
|
|
81
|
-
desc "status
|
84
|
+
desc "status", "Leverage Statuses API"
|
82
85
|
subcommand "status", GithubCLI::Commands::Statuses
|
83
86
|
|
84
|
-
desc "tag
|
87
|
+
desc "tag", "Leverage Tags API"
|
85
88
|
subcommand "tag", GithubCLI::Commands::Tags
|
86
89
|
|
87
|
-
desc "team
|
90
|
+
desc "team", "Leverage Teams API"
|
88
91
|
subcommand "team", GithubCLI::Commands::Teams
|
89
92
|
|
90
|
-
desc "tree
|
93
|
+
desc "tree", "Leverage Trees API"
|
91
94
|
subcommand "tree", GithubCLI::Commands::Trees
|
92
95
|
|
93
|
-
desc "user
|
96
|
+
desc "user", "Leverage Users API"
|
94
97
|
subcommand "user", GithubCLI::Commands::Users
|
95
98
|
|
96
|
-
desc "watch
|
99
|
+
desc "watch", "Leverage Watching API"
|
97
100
|
subcommand "watch", GithubCLI::Commands::Watching
|
98
101
|
|
99
102
|
end # CLI
|
data/lib/github_cli/thor_ext.rb
CHANGED
@@ -5,10 +5,6 @@ class Thor
|
|
5
5
|
|
6
6
|
class << self
|
7
7
|
|
8
|
-
def banner(command, namespace=nil, subcommand=false)
|
9
|
-
"#{command.formatted_usage(self, $thor_runner, subcommand)}"
|
10
|
-
end
|
11
|
-
|
12
8
|
def help(shell, subcommand = false)
|
13
9
|
list = printable_commands(true, subcommand)
|
14
10
|
Thor::Util.thor_classes_in(self).each do |klass|
|
@@ -30,7 +26,7 @@ class Thor
|
|
30
26
|
next if command.hidden?
|
31
27
|
item = []
|
32
28
|
item << banner(command, false, subcommand).gsub(/#{basename} /, '')
|
33
|
-
item << (command.description ? "#
|
29
|
+
item << (command.description ? " #{command.description.gsub(/\s+/m,' ')}" : "")
|
34
30
|
item
|
35
31
|
end.compact
|
36
32
|
end
|
@@ -71,7 +67,7 @@ class Thor
|
|
71
67
|
gcli-config.1
|
72
68
|
]
|
73
69
|
|
74
|
-
desc "help
|
70
|
+
desc "help", "Describe available commands or one specific command"
|
75
71
|
def help(task = nil, subcommand = false)
|
76
72
|
command = "gcli-#{task}.1"
|
77
73
|
|
data/lib/github_cli/version.rb
CHANGED
data/lib/github_cli.rb
CHANGED
@@ -0,0 +1,45 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe GithubCLI::Commands::Hooks do
|
6
|
+
let(:format) { 'table' }
|
7
|
+
let(:user) { 'peter-murach' }
|
8
|
+
let(:repo) { 'github_cli' }
|
9
|
+
let(:id) { 1 }
|
10
|
+
let(:api_class) { GithubCLI::Hook }
|
11
|
+
|
12
|
+
it "invokes hook:list" do
|
13
|
+
api_class.should_receive(:all).with(user, repo, {}, format)
|
14
|
+
subject.invoke "hook:list", [user, repo]
|
15
|
+
end
|
16
|
+
|
17
|
+
it "invokes hook:get" do
|
18
|
+
api_class.should_receive(:get).with(user, repo, id, {}, format)
|
19
|
+
subject.invoke "hook:get", [user, repo, id]
|
20
|
+
end
|
21
|
+
|
22
|
+
it "invokes hook:create --name --config" do
|
23
|
+
api_class.should_receive(:create).with(user, repo, {'name' => 'web',
|
24
|
+
"config" => { :url => "http://example.com/webhook" } }, format)
|
25
|
+
subject.invoke "hook:create", [user, repo], :name => 'web',
|
26
|
+
:config => {:url => "http://example.com/webhook" }
|
27
|
+
end
|
28
|
+
|
29
|
+
it "invokes hook:edit --name --config" do
|
30
|
+
api_class.should_receive(:edit).with(user, repo, id, {'name' => 'web',
|
31
|
+
"config" => { :url => "http://example.com/webhook" } }, format)
|
32
|
+
subject.invoke "hook:edit", [user, repo, id], :name => 'web',
|
33
|
+
:config => {:url => "http://example.com/webhook" }
|
34
|
+
end
|
35
|
+
|
36
|
+
it "invokes hook:test" do
|
37
|
+
api_class.should_receive(:test).with(user, repo, id, {}, format)
|
38
|
+
subject.invoke "hook:test", [user, repo, id]
|
39
|
+
end
|
40
|
+
|
41
|
+
it "invokes hook:delete" do
|
42
|
+
api_class.should_receive(:delete).with(user, repo, id, {}, format)
|
43
|
+
subject.invoke "hook:delete", [user, repo, id]
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe GithubCLI::Commands::Notifications do
|
6
|
+
let(:format) { 'table' }
|
7
|
+
let(:user) { 'peter-murach' }
|
8
|
+
let(:repo) { 'github_cli' }
|
9
|
+
let(:id) { 1 }
|
10
|
+
let(:api_class) { GithubCLI::Notification }
|
11
|
+
|
12
|
+
it "invokes notify:list" do
|
13
|
+
api_class.should_receive(:all).with({}, format)
|
14
|
+
subject.invoke "notify:list", []
|
15
|
+
end
|
16
|
+
|
17
|
+
it "invokes notify:list --user --repo" do
|
18
|
+
api_class.should_receive(:all).with({'user' => user, 'repo' => repo}, format)
|
19
|
+
subject.invoke "notify:list", [], :user => user, :repo => repo
|
20
|
+
end
|
21
|
+
|
22
|
+
it "invokes notify:get" do
|
23
|
+
api_class.should_receive(:get).with(id, {}, format)
|
24
|
+
subject.invoke "notify:get", [id]
|
25
|
+
end
|
26
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: github_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-04 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: github_api
|
16
|
-
requirement: &
|
16
|
+
requirement: &2156751040 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0.9'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2156751040
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &2156750320 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2156750320
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: aruba
|
38
|
-
requirement: &
|
38
|
+
requirement: &2156749380 !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: *
|
46
|
+
version_requirements: *2156749380
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
|
-
requirement: &
|
49
|
+
requirement: &2156748600 !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: *
|
57
|
+
version_requirements: *2156748600
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: communist
|
60
|
-
requirement: &
|
60
|
+
requirement: &2156748040 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2156748040
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: ronn
|
71
|
-
requirement: &
|
71
|
+
requirement: &2156747420 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2156747420
|
80
80
|
description: CLI-based access to GitHub API v3
|
81
81
|
email:
|
82
82
|
- ''
|
@@ -119,6 +119,7 @@ files:
|
|
119
119
|
- features/member.feature
|
120
120
|
- features/merging.feature
|
121
121
|
- features/milestone.feature
|
122
|
+
- features/notification.feature
|
122
123
|
- features/organization.feature
|
123
124
|
- features/pull_request.feature
|
124
125
|
- features/reference.feature
|
@@ -159,6 +160,7 @@ files:
|
|
159
160
|
- lib/github_cli/apis/member.rb
|
160
161
|
- lib/github_cli/apis/merging.rb
|
161
162
|
- lib/github_cli/apis/milestone.rb
|
163
|
+
- lib/github_cli/apis/notification.rb
|
162
164
|
- lib/github_cli/apis/organization.rb
|
163
165
|
- lib/github_cli/apis/pull_request.rb
|
164
166
|
- lib/github_cli/apis/reference.rb
|
@@ -196,6 +198,7 @@ files:
|
|
196
198
|
- lib/github_cli/commands/members.rb
|
197
199
|
- lib/github_cli/commands/merging.rb
|
198
200
|
- lib/github_cli/commands/milestones.rb
|
201
|
+
- lib/github_cli/commands/notifications.rb
|
199
202
|
- lib/github_cli/commands/organizations.rb
|
200
203
|
- lib/github_cli/commands/pull_requests.rb
|
201
204
|
- lib/github_cli/commands/references.rb
|
@@ -273,10 +276,12 @@ files:
|
|
273
276
|
- spec/github_cli/commands/events_spec.rb
|
274
277
|
- spec/github_cli/commands/followers_spec.rb
|
275
278
|
- spec/github_cli/commands/gists_spec.rb
|
279
|
+
- spec/github_cli/commands/hooks_spec.rb
|
276
280
|
- spec/github_cli/commands/issues_spec.rb
|
277
281
|
- spec/github_cli/commands/keys_spec.rb
|
278
282
|
- spec/github_cli/commands/labels_spec.rb
|
279
283
|
- spec/github_cli/commands/milestones_spec.rb
|
284
|
+
- spec/github_cli/commands/notifications_spec.rb
|
280
285
|
- spec/github_cli/commands/pull_requests_spec.rb
|
281
286
|
- spec/github_cli/commands/references_spec.rb
|
282
287
|
- spec/github_cli/commands/repositories_spec.rb
|
@@ -348,6 +353,7 @@ test_files:
|
|
348
353
|
- features/member.feature
|
349
354
|
- features/merging.feature
|
350
355
|
- features/milestone.feature
|
356
|
+
- features/notification.feature
|
351
357
|
- features/organization.feature
|
352
358
|
- features/pull_request.feature
|
353
359
|
- features/reference.feature
|
@@ -376,10 +382,12 @@ test_files:
|
|
376
382
|
- spec/github_cli/commands/events_spec.rb
|
377
383
|
- spec/github_cli/commands/followers_spec.rb
|
378
384
|
- spec/github_cli/commands/gists_spec.rb
|
385
|
+
- spec/github_cli/commands/hooks_spec.rb
|
379
386
|
- spec/github_cli/commands/issues_spec.rb
|
380
387
|
- spec/github_cli/commands/keys_spec.rb
|
381
388
|
- spec/github_cli/commands/labels_spec.rb
|
382
389
|
- spec/github_cli/commands/milestones_spec.rb
|
390
|
+
- spec/github_cli/commands/notifications_spec.rb
|
383
391
|
- spec/github_cli/commands/pull_requests_spec.rb
|
384
392
|
- spec/github_cli/commands/references_spec.rb
|
385
393
|
- spec/github_cli/commands/repositories_spec.rb
|