github_cli 0.5.5 → 0.5.6

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ 0.5.6 (April 1, 2013)
2
+
3
+ * Change gcli interface to be more concise and not include gcli name
4
+ * Change issue command to add specific options and add tests
5
+ * Change user command to add specific options and add tests
6
+ * Change team command to add specific options and add tests
7
+
1
8
  0.5.5 (March 30, 2013)
2
9
 
3
10
  * Change PullRequest commands to take specific options and add tests
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- github_cli (0.5.5)
4
+ github_cli (0.5.6)
5
5
  github_api (~> 0.9)
6
6
 
7
7
  GEM
@@ -5,8 +5,8 @@ Feature: gcli assignee
5
5
 
6
6
  When I run `gcli assignee`
7
7
  Then the exit status should be 0
8
- And the output should contain "gcli assignee list"
9
- And the output should contain "gcli assignee check"
8
+ And the output should contain "assignee list"
9
+ And the output should contain "assignee check"
10
10
 
11
11
  Scenario: List assignees
12
12
  Given the GitHub API server:
@@ -5,8 +5,8 @@ Feature: gcli blob
5
5
 
6
6
  When I run `gcli blob`
7
7
  Then the exit status should be 0
8
- And the output should contain "gcli blob get"
9
- And the output should contain "gcli blob create"
8
+ And the output should contain "blob get"
9
+ And the output should contain "blob create"
10
10
 
11
11
  Scenario: Get blob
12
12
  Given the GitHub API server:
@@ -5,10 +5,10 @@ Feature: gcli collab
5
5
 
6
6
  When I run `gcli collab`
7
7
  Then the exit status should be 0
8
- And the output should contain "gcli collab list"
9
- And the output should contain "gcli collab add"
10
- And the output should contain "gcli collab collab"
11
- And the output should contain "gcli collab remove"
8
+ And the output should contain "collab list"
9
+ And the output should contain "collab add"
10
+ And the output should contain "collab collab"
11
+ And the output should contain "collab remove"
12
12
 
13
13
  Scenario: List collaborators
14
14
  Given the GitHub API server:
@@ -5,8 +5,8 @@ Feature: gcli commit
5
5
 
6
6
  When I run `gcli commit`
7
7
  Then the exit status should be 0
8
- And the output should contain "gcli commit get"
9
- And the output should contain "gcli commit create"
8
+ And the output should contain "commit get"
9
+ And the output should contain "commit create"
10
10
 
11
11
  Scenario: Get commit
12
12
  Given the GitHub API server:
@@ -5,9 +5,9 @@ Feature: gcli email
5
5
 
6
6
  When I run `gcli email`
7
7
  Then the exit status should be 0
8
- And the output should contain "gcli email delete"
9
- And the output should contain "gcli email list"
10
- And the output should contain "gcli email add"
8
+ And the output should contain "email delete"
9
+ And the output should contain "email list"
10
+ And the output should contain "email add"
11
11
 
12
12
  Scenario: List emails
13
13
  Given the GitHub API server:
@@ -5,14 +5,14 @@ Feature: gcli event
5
5
 
6
6
  When I run `gcli event`
7
7
  Then the exit status should be 0
8
- And the output should contain "gcli event issue"
9
- And the output should contain "gcli event network"
10
- And the output should contain "gcli event org"
11
- And the output should contain "gcli event performed"
12
- And the output should contain "gcli event public"
13
- And the output should contain "gcli event received"
14
- And the output should contain "gcli event repo"
15
- And the output should contain "gcli event user_org"
8
+ And the output should contain "event issue"
9
+ And the output should contain "event network"
10
+ And the output should contain "event org"
11
+ And the output should contain "event performed"
12
+ And the output should contain "event public"
13
+ And the output should contain "event received"
14
+ And the output should contain "event repo"
15
+ And the output should contain "event user_org"
16
16
 
17
17
  Scenario: Public events
18
18
  Given the GitHub API server:
@@ -5,11 +5,11 @@ Feature: gcli follower
5
5
 
6
6
  When I run `gcli follower`
7
7
  Then the exit status should be 0
8
- And the output should contain "gcli follower follow"
9
- And the output should contain "gcli follower follower"
10
- And the output should contain "gcli follower following"
11
- And the output should contain "gcli follower list"
12
- And the output should contain "gcli follower unfollow"
8
+ And the output should contain "follower follow"
9
+ And the output should contain "follower follower"
10
+ And the output should contain "follower following"
11
+ And the output should contain "follower list"
12
+ And the output should contain "follower unfollow"
13
13
 
14
14
  Scenario: List for user
15
15
  Given the GitHub API server:
@@ -5,15 +5,15 @@ Feature: gcli gist
5
5
 
6
6
  When I run `gcli gist`
7
7
  Then the exit status should be 0
8
- And the output should contain "gcli gist create"
9
- And the output should contain "gcli gist delete"
10
- And the output should contain "gcli gist edit"
11
- And the output should contain "gcli gist get"
12
- And the output should contain "gcli gist fork"
13
- And the output should contain "gcli gist list"
14
- And the output should contain "gcli gist star"
15
- And the output should contain "gcli gist starred"
16
- And the output should contain "gcli gist unstar"
8
+ And the output should contain "gist create"
9
+ And the output should contain "gist delete"
10
+ And the output should contain "gist edit"
11
+ And the output should contain "gist get"
12
+ And the output should contain "gist fork"
13
+ And the output should contain "gist list"
14
+ And the output should contain "gist star"
15
+ And the output should contain "gist starred"
16
+ And the output should contain "gist unstar"
17
17
 
18
18
  Scenario: List gists for user
19
19
  Given the GitHub API server:
@@ -1,19 +1,27 @@
1
1
  Feature: gcli issue
2
2
 
3
+ @ci-run
3
4
  Scenario: Available commands
4
5
  When I run `gcli issue`
5
6
  Then the exit status should be 0
6
- And the output should contain "gcli issue create"
7
- And the output should contain "gcli issue edit"
8
- And the output should contain "gcli issue get"
9
- And the output should contain "gcli issue list"
10
- And the output should contain "gcli issue repo"
7
+ And the output should contain "issue create"
8
+ And the output should contain "issue edit"
9
+ And the output should contain "issue get"
10
+ And the output should contain "issue list"
11
11
 
12
- Scenario: List issues
12
+ Scenario: List all issues
13
13
  Given the GitHub API server:
14
14
  """
15
15
  get('/issues') { status 200 }
16
16
  """
17
+ When I run `gcli issue ls --all`
18
+ Then the exit status should be 0
19
+
20
+ Scenario: List issues for authenticated user
21
+ Given the GitHub API server:
22
+ """
23
+ get('/user/issues') { status 200 }
24
+ """
17
25
  When I run `gcli issue ls`
18
26
  Then the exit status should be 0
19
27
 
@@ -22,7 +30,15 @@ Feature: gcli issue
22
30
  """
23
31
  get('/repos/wycats/thor/issues') { status 200 }
24
32
  """
25
- When I run `gcli issue repo wycats thor`
33
+ When I run `gcli issue ls --user wycats --repo thor`
34
+ Then the exit status should be 0
35
+
36
+ Scenario: List issues for an organization
37
+ Given the GitHub API server:
38
+ """
39
+ get('/orgs/rails/issues') { status 200 }
40
+ """
41
+ When I run `gcli issue ls --org rails`
26
42
  Then the exit status should be 0
27
43
 
28
44
  Scenario: Get issue
@@ -38,7 +54,7 @@ Feature: gcli issue
38
54
  """
39
55
  post('/repos/wycats/thor/issues') { status 200 }
40
56
  """
41
- When I run `gcli issue create wycats thor --params=title:'Found a bug'`
57
+ When I run `gcli issue create wycats thor --title 'Found a bug'`
42
58
  Then the exit status should be 0
43
59
 
44
60
  Scenario: Edit issue
@@ -46,6 +62,6 @@ Feature: gcli issue
46
62
  """
47
63
  patch('/repos/wycats/thor/issues/1') { status 200 }
48
64
  """
49
- When I run `gcli issue edit wycats thor 1 --params=title:'Found a bug'`
65
+ When I run `gcli issue edit wycats thor 1 --title 'Found a bug'`
50
66
  Then the exit status should be 0
51
67
 
data/features/key.feature CHANGED
@@ -4,11 +4,11 @@ Feature: gcli key
4
4
  Scenario: Available commands
5
5
  When I run `gcli key`
6
6
  Then the exit status should be 0
7
- And the output should contain "gcli key create"
8
- And the output should contain "gcli key delete"
9
- And the output should contain "gcli key edit"
10
- And the output should contain "gcli key get"
11
- And the output should contain "gcli key list"
7
+ And the output should contain "key create"
8
+ And the output should contain "key delete"
9
+ And the output should contain "key edit"
10
+ And the output should contain "key get"
11
+ And the output should contain "key list"
12
12
 
13
13
  Scenario: List keys
14
14
  Given the GitHub API server:
@@ -5,11 +5,11 @@ Feature: gcli milestone
5
5
 
6
6
  When I run `gcli milestone`
7
7
  Then the exit status should be 0
8
- And the output should contain "gcli milestone create"
9
- And the output should contain "gcli milestone delete"
10
- And the output should contain "gcli milestone get"
11
- And the output should contain "gcli milestone list"
12
- And the output should contain "gcli milestone update"
8
+ And the output should contain "milestone create"
9
+ And the output should contain "milestone delete"
10
+ And the output should contain "milestone get"
11
+ And the output should contain "milestone list"
12
+ And the output should contain "milestone update"
13
13
 
14
14
  Scenario: List milestones
15
15
  Given the GitHub API server:
@@ -5,14 +5,14 @@ Feature: gcli pull request
5
5
 
6
6
  When I run `gcli pull`
7
7
  Then the exit status should be 0
8
- And the output should contain "gcli pull commits"
9
- And the output should contain "gcli pull create"
10
- And the output should contain "gcli pull files"
11
- And the output should contain "gcli pull get"
12
- And the output should contain "gcli pull list"
13
- And the output should contain "gcli pull merge"
14
- And the output should contain "gcli pull merged"
15
- And the output should contain "gcli pull update"
8
+ And the output should contain "pull commits"
9
+ And the output should contain "pull create"
10
+ And the output should contain "pull files"
11
+ And the output should contain "pull get"
12
+ And the output should contain "pull list"
13
+ And the output should contain "pull merge"
14
+ And the output should contain "pull merged"
15
+ And the output should contain "pull update"
16
16
 
17
17
  Scenario: List pull requests
18
18
  Given the GitHub API server:
@@ -5,11 +5,11 @@ Feature: gcli ref
5
5
 
6
6
  When I run `gcli ref`
7
7
  Then the exit status should be 0
8
- And the output should contain "gcli ref create"
9
- And the output should contain "gcli ref delete"
10
- And the output should contain "gcli ref get"
11
- And the output should contain "gcli ref list"
12
- And the output should contain "gcli ref update"
8
+ And the output should contain "ref create"
9
+ And the output should contain "ref delete"
10
+ And the output should contain "ref get"
11
+ And the output should contain "ref list"
12
+ And the output should contain "ref update"
13
13
 
14
14
  Scenario: List all references
15
15
  Given the GitHub API server:
@@ -4,17 +4,17 @@ Feature: gcli repository
4
4
  Scenario: Available commands
5
5
  When I run `gcli repo`
6
6
  Then the exit status should be 0
7
- And the output should contain "gcli repo branch"
8
- And the output should contain "gcli repo branches"
9
- And the output should contain "gcli repo contribs"
10
- And the output should contain "gcli repo create"
11
- And the output should contain "gcli repo edit"
12
- And the output should contain "gcli repo delete"
13
- And the output should contain "gcli repo get"
14
- And the output should contain "gcli repo list"
15
- And the output should contain "gcli repo langs"
16
- And the output should contain "gcli repo tags"
17
- And the output should contain "gcli repo teams"
7
+ And the output should contain "repo branch"
8
+ And the output should contain "repo branches"
9
+ And the output should contain "repo contribs"
10
+ And the output should contain "repo create"
11
+ And the output should contain "repo edit"
12
+ And the output should contain "repo delete"
13
+ And the output should contain "repo get"
14
+ And the output should contain "repo list"
15
+ And the output should contain "repo langs"
16
+ And the output should contain "repo tags"
17
+ And the output should contain "repo teams"
18
18
 
19
19
  Scenario: List all repositories
20
20
  Given the GitHub API server:
@@ -5,11 +5,11 @@ Feature: gcli star
5
5
 
6
6
  When I run `gcli star`
7
7
  Then the exit status should be 0
8
- And the output should contain "gcli star list"
9
- And the output should contain "gcli star star"
10
- And the output should contain "gcli star unstar"
11
- And the output should contain "gcli star starred"
12
- And the output should contain "gcli star starring"
8
+ And the output should contain "star list"
9
+ And the output should contain "star star"
10
+ And the output should contain "star unstar"
11
+ And the output should contain "star starred"
12
+ And the output should contain "star starring"
13
13
 
14
14
  Scenario: List stargazers
15
15
  Given the GitHub API server:
data/features/tag.feature CHANGED
@@ -5,8 +5,8 @@ Feature: gcli tag
5
5
 
6
6
  When I run `gcli tag`
7
7
  Then the exit status should be 0
8
- And the output should contain "gcli tag create"
9
- And the output should contain "gcli tag get"
8
+ And the output should contain "tag create"
9
+ And the output should contain "tag get"
10
10
 
11
11
  Scenario: Get tag
12
12
  Given the GitHub API server:
@@ -1,21 +1,22 @@
1
1
  Feature: gcli team
2
2
 
3
+ @ci-run
3
4
  Scenario: Available commands
4
5
  When I run `gcli team`
5
6
  Then the exit status should be 0
6
- And the output should contain "gcli team add_member"
7
- And the output should contain "gcli team add_repo"
8
- And the output should contain "gcli team create"
9
- And the output should contain "gcli team delete"
10
- And the output should contain "gcli team edit"
11
- And the output should contain "gcli team get"
12
- And the output should contain "gcli team list"
13
- And the output should contain "gcli team list_member"
14
- And the output should contain "gcli team list_repo"
15
- And the output should contain "gcli team member"
16
- And the output should contain "gcli team remove_member"
17
- And the output should contain "gcli team remove_repo"
18
- And the output should contain "gcli team repo"
7
+ And the output should contain "team add_member"
8
+ And the output should contain "team add_repo"
9
+ And the output should contain "team create"
10
+ And the output should contain "team delete"
11
+ And the output should contain "team edit"
12
+ And the output should contain "team get"
13
+ And the output should contain "team list"
14
+ And the output should contain "team list_member"
15
+ And the output should contain "team list_repo"
16
+ And the output should contain "team member"
17
+ And the output should contain "team remove_member"
18
+ And the output should contain "team remove_repo"
19
+ And the output should contain "team repo"
19
20
 
20
21
  Scenario: List all teams
21
22
  Given the GitHub API server:
@@ -5,8 +5,8 @@ Feature: gcli tree
5
5
 
6
6
  When I run `gcli tree`
7
7
  Then the exit status should be 0
8
- And the output should contain "gcli tree create"
9
- And the output should contain "gcli tree get"
8
+ And the output should contain "tree create"
9
+ And the output should contain "tree get"
10
10
 
11
11
  Scenario: Get tree
12
12
  Given the GitHub API server:
@@ -1,11 +1,20 @@
1
1
  Feature: gcli user
2
2
 
3
+ @ci-run
3
4
  Scenario: Available commands
4
5
 
5
6
  When I run `gcli user`
6
7
  Then the exit status should be 0
7
- And the output should contain "gcli user get"
8
- And the output should contain "gcli user update"
8
+ And the output should contain "user get"
9
+ And the output should contain "user update"
10
+
11
+ Scenario: List all users
12
+ Given the GitHub API server:
13
+ """
14
+ get('/users') { status 200 }
15
+ """
16
+ When I run `gcli user ls`
17
+ Then the exit status should be 0
9
18
 
10
19
  Scenario: Get user
11
20
  Given the GitHub API server:
@@ -28,5 +37,5 @@ Feature: gcli user
28
37
  """
29
38
  patch('/user') { status 200 }
30
39
  """
31
- When I run `gcli user update --params=name:peter-murach`
40
+ When I run `gcli user update --name=peter-murach`
32
41
  Then the exit status should be 0
@@ -5,11 +5,11 @@ Feature: gcli watching
5
5
 
6
6
  When I run `gcli watch`
7
7
  Then the exit status should be 0
8
- And the output should contain "gcli watch list"
9
- And the output should contain "gcli watch start"
10
- And the output should contain "gcli watch stop"
11
- And the output should contain "gcli watch watched"
12
- And the output should contain "gcli watch watching"
8
+ And the output should contain "watch list"
9
+ And the output should contain "watch start"
10
+ And the output should contain "watch stop"
11
+ And the output should contain "watch watched"
12
+ And the output should contain "watch watching"
13
13
 
14
14
  Scenario: List watchers
15
15
  Given the GitHub API server:
@@ -5,15 +5,9 @@ module GithubCLI
5
5
 
6
6
  class << self
7
7
 
8
- def all(params, format)
8
+ def all(arg, params, format)
9
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, repo, params
10
+ github_api.issues.list arg, params
17
11
  end
18
12
  end
19
13
 
@@ -11,9 +11,9 @@ module GithubCLI
11
11
  end
12
12
  end
13
13
 
14
- def get(user, params, format)
14
+ def get(params, format)
15
15
  output format do
16
- github_api.users.get params.update(:user => user)
16
+ github_api.users.get params
17
17
  end
18
18
  end
19
19
 
@@ -68,7 +68,7 @@ module GithubCLI
68
68
  end
69
69
  end
70
70
 
71
- desc 'init [<filename>]', 'Generates a configuration file in your home directory'
71
+ desc 'init [<filename>]', '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
@@ -5,7 +5,7 @@ module GithubCLI
5
5
  class Command
6
6
  class Usage
7
7
 
8
- DEFAULT_INDENT = 11
8
+ DEFAULT_INDENT = 12
9
9
 
10
10
  # Returns command
11
11
  attr_reader :command
@@ -5,9 +5,32 @@ module GithubCLI
5
5
 
6
6
  namespace :issue
7
7
 
8
- desc 'list', 'List all issues'
8
+ option :filter, :type => :string,
9
+ :banner => "assigned|created|mentioned|subscribed|all"
10
+ option :milstone, :type => :string,
11
+ :banner => "number|none|*"
12
+ option :creator, :type => :string,
13
+ :desc => "user login"
14
+ option :mentioned, :type => :string,
15
+ :desc => "user login"
16
+ option :state, :type => :string, :banner => "open|closed",
17
+ :desc => "open, closed, default: open"
18
+ option :labels, :type => :array,
19
+ :desc => "list of comma separated Label names. Example: bug,ui,@high"
20
+ option :sort, :type => :string, :banner => "created|updated|comments",
21
+ :desc => "created, updated, comments, default: created"
22
+ option :direction, :type => :string, :banner => "asc|desc",
23
+ :desc => "asc or desc, default: desc"
24
+ option :since, :type => :string,
25
+ :desc => "string of a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ"
26
+ option :org, :type => :string, :aliases => ["-o"]
27
+ option :user, :type => :string, :aliases => ["-u"]
28
+ option :repo, :type => :string, :aliases => ["-r"]
29
+ option :all, :type => :boolean,
30
+ :desc => "List all issues across all the authenticated user’s visible repositories"
31
+ desc 'list', 'List issues'
9
32
  long_desc <<-DESC
10
- ghc issue list --params filter:'assigned', state:'open'
33
+ ghc issue list --filter=assigned --state=open
11
34
 
12
35
  Parameters
13
36
 
@@ -16,44 +39,56 @@ module GithubCLI
16
39
  * created: Issues assigned to you (default) \n
17
40
  * mentioned: Issues assigned to you (default)\n
18
41
  * subscribed: Issues assigned to you (default)\n
19
- state - open, closed, default: open \n
20
- labels - String list of comma separated Label names. Example: bug,ui,@high
21
- sort - created, updated, comments, default: created \n
22
- direction - asc, desc, default: desc \n
23
- since - Optional string of a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ \n
24
- DESC
25
- def list
26
- Issue.all options[:params], options[:format]
27
- end
28
-
29
- desc 'repo <user> <repo>', 'List all issues for a repository'
30
- long_desc <<-DESC
31
- Parameters
32
-
33
42
  milestone:\n
34
43
  * Integer Milestone number\n
35
44
  * none for Issues with no Milestone.\n
36
45
  * * for Issues with any Milestone\n
37
- state - open, closed, default: open \n
38
46
  assignee:\n
39
47
  * String User login\n
40
48
  * none for Issues with no assigned User.\n
41
49
  * * for Issues with any assigned User.\n
42
- mentioned - String User login\n
43
- labels - String list of comma separated Label names. Example: bug,ui,@high\n
44
- sort - created, updated, comments, default: created\n
45
- direction - asc, desc, default: desc\n
46
- since - Optional string of a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ\n
50
+ creator - string - user login\n
51
+ mentioned - string - user login\n
52
+ state - open, closed, default: open \n
53
+ labels - String list of comma separated Label names. Example: bug,ui,@high
54
+ sort - created, updated, comments, default: created \n
55
+ direction - asc, desc, default: desc \n
56
+ since - Optional string of a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ \n
47
57
  DESC
48
- def repo(user, repo)
49
- Issue.all_repo user, repo, options[:params], options[:format]
58
+ def list
59
+ params = options[:params].dup
60
+ params['org'] = options[:org] if options[:org]
61
+ params['user'] = options[:user] if options[:user]
62
+ params['repo'] = options[:repo] if options[:repo]
63
+ params['filter'] = options[:filter] if options[:filter]
64
+ params['milestone'] = options[:milestone] if options[:milestone]
65
+ params['assignee'] = options[:assignee] if options[:assignee]
66
+ params['creator'] = options[:creator] if options[:creator]
67
+ params['mentioned'] = options[:mentioned] if options[:mentioned]
68
+ params['sort'] = options[:sort] if options[:sort]
69
+ params['state'] = options[:state] if options[:state]
70
+ params['labels'] = options[:labels] if options[:labels]
71
+ params['direction'] = options[:direction] if options[:direction]
72
+ params['since'] = options[:since] if options[:since]
73
+
74
+ arg = []
75
+ arg = :user if !options[:all] && !(options[:user] || options[:org])
76
+ Issue.all arg, params, options[:format]
50
77
  end
51
78
 
52
- desc 'get <user> <repo> <issue-id>', 'Get a single issue'
53
- def get(user, repo, id)
54
- Issue.get user, repo, id, options[:params], options[:format]
79
+ desc 'get <user> <repo> <number>', 'Get a single issue'
80
+ def get(user, repo, number)
81
+ Issue.get user, repo, number, options[:params], options[:format]
55
82
  end
56
83
 
84
+ option :title, :type => :string, :required => true
85
+ option :body, :type => :string
86
+ option :assignee, :type => :string,
87
+ :desc => "Login for the user that this issue should be assigned to."
88
+ option :milestone, :type => :numeric,
89
+ :desc => "Milestone to associate this issue with."
90
+ option :labels, :type => :array,
91
+ :desc => "Labels to associate with this issue."
57
92
  desc 'create <user> <repo>', 'Create an issue.'
58
93
  long_desc <<-DESC
59
94
  Parameters
@@ -66,13 +101,30 @@ module GithubCLI
66
101
 
67
102
  Example
68
103
 
69
- ghc issue create wycats thor --params=title:'Found a bug'
104
+ ghc issue create wycats thor --title='Found a bug'
70
105
  DESC
71
106
  def create(user, repo)
72
- Issue.create user, repo, options[:params], options[:format]
107
+ params = options[:params].dup
108
+ params['title'] = options[:title]
109
+ params['body'] = options[:body] if options[:body]
110
+ params['assignee'] = options[:assignee] if options[:assignee]
111
+ params['milestone'] = options[:milestone] if options[:milestone]
112
+ params['labels'] = options[:labels] if options[:labels]
113
+
114
+ Issue.create user, repo, params, options[:format]
73
115
  end
74
116
 
75
- desc 'edit <user> <repo> <issue-id>', 'Edit an issue.'
117
+ option :title, :type => :string, :required => true
118
+ option :body, :type => :string
119
+ option :assignee, :type => :string,
120
+ :desc => "Login for the user that this issue should be assigned to."
121
+ option :milestone, :type => :string,
122
+ :desc => "Milestone to associate this issue with."
123
+ option :labels, :type => :array,
124
+ :desc => "Labels to associate with this issue."
125
+ option :state, :type => :string, :banner => "open|closed",
126
+ :desc => "open, closed, default: open"
127
+ desc 'edit <user> <repo> <number>', 'Edit an issue.'
76
128
  long_desc <<-DESC
77
129
  Parameters
78
130
 
@@ -85,10 +137,18 @@ module GithubCLI
85
137
 
86
138
  Example
87
139
 
88
- ghc issue edit wycats thor 1 --params=title:'Found a bug'
140
+ ghc issue edit wycats thor 1 --title='Found a bug'
89
141
  DESC
90
- def edit(user, repo, id)
91
- Issue.edit user, repo, id, options[:params], options[:format]
142
+ def edit(user, repo, number)
143
+ params = options[:params].dup
144
+ params['title'] = options[:title]
145
+ params['body'] = options[:body] if options[:body]
146
+ params['assignee'] = options[:assignee] if options[:assignee]
147
+ params['milestone'] = options[:milestone] if options[:milestone]
148
+ params['labels'] = options[:labels] if options[:labels]
149
+ params['state'] = options[:state] if options[:state]
150
+
151
+ Issue.edit user, repo, number, params, options[:format]
92
152
  end
93
153
 
94
154
  end # Issues
@@ -10,11 +10,14 @@ module GithubCLI
10
10
  Team.all org, options[:params], options[:format]
11
11
  end
12
12
 
13
- desc 'get <team-id>', "Get a team"
13
+ desc 'get <id>', "Get a team"
14
14
  def get(id)
15
15
  Team.get id, options[:params], options[:format]
16
16
  end
17
17
 
18
+ option :name, :type => :string, :required => true
19
+ option :repo_names, :type => :array
20
+ option :permission, :type => :string, :banner => "pull|push|admin"
18
21
  desc 'create <org>', "Create a team"
19
22
  long_desc <<-DESC
20
23
  In order to create a team, the authenticated user must be an owner of :org.
@@ -29,10 +32,17 @@ module GithubCLI
29
32
  * admin - team members can pull, push and administor these repositories.\n
30
33
  DESC
31
34
  def create(org)
32
- Team.create org, options[:params], options[:format]
35
+ params = options[:params].dup
36
+ params['name'] = options[:name]
37
+ params['repo_names'] = options[:repo_names] if options[:repo_names]
38
+ params['permission'] = options[:permission] if options[:permission]
39
+
40
+ Team.create org, params, options[:format]
33
41
  end
34
42
 
35
- desc 'edit <team-id>', "Edit team <team-id>"
43
+ option :name, :type => :string, :required => true
44
+ option :permission, :type => :string, :banner => "pull|push|admin"
45
+ desc 'edit <id>', "Edit team <id>"
36
46
  long_desc <<-DESC
37
47
  In order to edit a team, the authenticated user must be an owner of the org that the team is associated with.
38
48
 
@@ -45,10 +55,14 @@ module GithubCLI
45
55
  * admin - team members can pull, push and administor these repositories.\n
46
56
  DESC
47
57
  def edit(id)
48
- Team.edit id, options[:params], options[:format]
58
+ params = options[:params].dup
59
+ params['name'] = options[:name]
60
+ params['permission'] = options[:permission] if options[:permission]
61
+
62
+ Team.edit id, params, options[:format]
49
63
  end
50
64
 
51
- desc 'delete <team-id>', 'Delete team <team-id>'
65
+ desc 'delete <id>', 'Delete team <id>'
52
66
  long_desc <<-DESC
53
67
  In order to delete a team, the authenticated user must be an owner of the org that the team is associated with.
54
68
  DESC
@@ -56,12 +70,12 @@ module GithubCLI
56
70
  Team.delete id, options[:params], options[:format]
57
71
  end
58
72
 
59
- desc 'list_member <team-id>', "List team <team-id> members"
73
+ desc 'list_member <id>', "List team <id> members"
60
74
  def list_member(id)
61
75
  Team.all_member id, options[:params], options[:format]
62
76
  end
63
77
 
64
- desc 'member <team-id> <user>', 'Check if <user> is a team member'
78
+ desc 'member <id> <user>', 'Check if <user> is a team member'
65
79
  long_desc <<-DESC
66
80
  In order to get if a user is a member of a team, the authenticated user must be a member of the team.
67
81
  DESC
@@ -69,7 +83,7 @@ module GithubCLI
69
83
  Team.member id, user, options[:params], options[:format]
70
84
  end
71
85
 
72
- desc 'add_member <team-id> <user>', 'Add team member'
86
+ desc 'add_member <id> <user>', 'Add team member'
73
87
  long_desc <<-DESC
74
88
  In order to add a user to a team, the authenticated user must have ‘admin’ permissions to the team or be an owner of the org that the team is associated with.
75
89
  DESC
@@ -77,7 +91,7 @@ module GithubCLI
77
91
  Team.add_member id, user, options[:params], options[:format]
78
92
  end
79
93
 
80
- desc 'remove_member <team-id> <user>', 'Remove team member'
94
+ desc 'remove_member <id> <user>', 'Remove team member'
81
95
  long_desc <<-DESC
82
96
  In order to remove a user from a team, the authenticated user must have
83
97
  ‘admin’ permissions to the team or be an owner of the org that the team
@@ -88,17 +102,17 @@ module GithubCLI
88
102
  Team.remove_member id, user, options[:params], options[:format]
89
103
  end
90
104
 
91
- desc 'list_repo <team-id>', "List team <team-id> repositories"
105
+ desc 'list_repo <id>', "List team <id> repositories"
92
106
  def list_repo(id)
93
107
  Team.all_repo id, options[:params], options[:format]
94
108
  end
95
109
 
96
- desc 'repo <team-id> <user> <repo>', 'Check if <repo> is managed by <team-id> team'
110
+ desc 'repo <id> <user> <repo>', 'Check if <repo> is managed by team <id>'
97
111
  def repo(id, user, repo)
98
112
  Team.repo id, user, repo, options[:params], options[:format]
99
113
  end
100
114
 
101
- desc 'add_repo <team-id> <user> <repo>', 'Add team <repo>'
115
+ desc 'add_repo <id> <user> <repo>', 'Add team <repo>'
102
116
  long_desc <<-DESC
103
117
  In order to add a repo to a team, the authenticated user must be an owner
104
118
  of the org that the team is associated with. Also, the repo must be owned
@@ -108,7 +122,7 @@ module GithubCLI
108
122
  Team.add_repo id, user, repo, options[:params], options[:format]
109
123
  end
110
124
 
111
- desc 'remove_repo <team-id> <user> <repo>', 'Remove team <repo>'
125
+ desc 'remove_repo <id> <user> <repo>', 'Remove team <repo>'
112
126
  long_desc <<-DESC
113
127
  In order to remove a repo from a team, the authenticated user must be an
114
128
  owner of the org that the team is associated with. NOTE: This does not
@@ -19,7 +19,9 @@ module GithubCLI
19
19
  :desc => 'Get a single unauthenticated <user>',
20
20
  :banner => '<user>'
21
21
  def get
22
- User.get options[:user], options[:params], options[:format]
22
+ params = options[:params].dup
23
+ params['user'] = options[:user] if options[:user]
24
+ User.get params, options[:format]
23
25
  end
24
26
 
25
27
  desc 'update', 'Update the authenticated user'
@@ -5,21 +5,38 @@ 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
+
8
12
  def help(shell, subcommand = false)
9
- list = printable_tasks(true, subcommand)
13
+ list = printable_commands(true, subcommand)
10
14
  Thor::Util.thor_classes_in(self).each do |klass|
11
- list += klass.printable_tasks(false)
15
+ list += klass.printable_commands(false)
12
16
  end
13
17
  list.sort!{ |a,b| a[0] <=> b[0] }
14
18
 
15
19
  GithubCLI::Terminal.print_usage global_flags, list[0][0]
16
20
 
17
21
  shell.say "Commands:"
18
- shell.print_table(list, :indent => 2, :truncate => true)
22
+ shell.print_table(list, :indent => 3, :truncate => true)
19
23
  shell.say
20
24
  class_options_help(shell)
21
25
  end
22
26
 
27
+ # Returns commands ready to be printed.
28
+ def printable_commands(all = true, subcommand = false)
29
+ (all ? all_commands : commands).map do |_, command|
30
+ next if command.hidden?
31
+ item = []
32
+ item << banner(command, false, subcommand).gsub(/#{basename} /, '')
33
+ item << (command.description ? "# #{command.description.gsub(/\s+/m,' ')}" : "")
34
+ item
35
+ end.compact
36
+ end
37
+ alias printable_tasks printable_commands
38
+
39
+
23
40
  # String representation of all available global flags
24
41
  def global_flags
25
42
  return if class_options.empty?
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module GithubCLI
4
- VERSION = "0.5.5"
4
+ VERSION = "0.5.6"
5
5
  end
@@ -0,0 +1,62 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe GithubCLI::Commands::Issues do
6
+ let(:format) { 'table' }
7
+ let(:user) { 'peter-murach' }
8
+ let(:repo) { 'github_cli' }
9
+ let(:org) { 'github' }
10
+ let(:number) { 1 }
11
+ let(:api_class) { GithubCLI::Issue }
12
+
13
+ it "invokes issue:list" do
14
+ api_class.should_receive(:all).with(:user, {}, format)
15
+ subject.invoke "issue:list", []
16
+ end
17
+
18
+ it "invokes issue:list --all" do
19
+ api_class.should_receive(:all).with([], {}, format)
20
+ subject.invoke "issue:list", [], :all => true
21
+ end
22
+
23
+ it "invokes issue:list --org" do
24
+ api_class.should_receive(:all).with([], {"org" => org}, format)
25
+ subject.invoke "issue:list", [], :org => org
26
+ end
27
+
28
+ it "invokes issue:list --user --repo" do
29
+ api_class.should_receive(:all).with([], {"user" => user, "repo" => repo}, format)
30
+ subject.invoke "issue:list", [], :user => user, :repo => repo
31
+ end
32
+
33
+ it "invokes issue:get" do
34
+ api_class.should_receive(:get).with(user, repo, number, {}, format)
35
+ subject.invoke "issue:get", [user, repo, number]
36
+ end
37
+
38
+ it "invokes issue:create --title" do
39
+ api_class.should_receive(:create).with(user, repo, {"title" => 'new'}, format)
40
+ subject.invoke "issue:create", [user, repo], :title => 'new'
41
+ end
42
+
43
+ it "invokes issue:create --title --milestone" do
44
+ api_class.should_receive(:create).with(user, repo, {"title" => 'new',
45
+ 'milestone' => 1}, format)
46
+ subject.invoke "issue:create", [user, repo], :title => 'new', :milestone => 1
47
+ end
48
+
49
+ it "invokes issue:edit --title" do
50
+ api_class.should_receive(:edit).with(user, repo, number,
51
+ {"title" => 'new'}, format)
52
+ subject.invoke "issue:edit", [user, repo, number], :title => 'new'
53
+ end
54
+
55
+ it "invokes issue:edit --title --milestone" do
56
+ api_class.should_receive(:edit).with(user, repo, number, {"title" => 'new',
57
+ 'milestone' => number}, format)
58
+ subject.invoke "issue:edit", [user, repo, number], :title => 'new',
59
+ :milestone => number
60
+ end
61
+
62
+ end
@@ -0,0 +1,77 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe GithubCLI::Commands::Teams do
6
+ let(:format) { 'table' }
7
+ let(:user) { 'peter-murach' }
8
+ let(:repo) { 'github_cli' }
9
+ let(:org) { 'rails' }
10
+ let(:id) { 1 }
11
+ let(:api_class) { GithubCLI::Team }
12
+
13
+ it "invokes team:list" do
14
+ api_class.should_receive(:all).with(org, {}, format)
15
+ subject.invoke "team:list", [org]
16
+ end
17
+
18
+ it "invokes team:get" do
19
+ api_class.should_receive(:get).with(id, {}, format)
20
+ subject.invoke "team:get", [id]
21
+ end
22
+
23
+ it "invokes team:create --name" do
24
+ api_class.should_receive(:create).with(org, {"name" => 'new'}, format)
25
+ subject.invoke "team:create", [org], :name => 'new'
26
+ end
27
+
28
+ it "invokes team:edit --name" do
29
+ api_class.should_receive(:edit).with(id, {"name" => 'new'}, format)
30
+ subject.invoke "team:edit", [id], :name => 'new'
31
+ end
32
+
33
+ it "invokes team:delete" do
34
+ api_class.should_receive(:delete).with(id, {}, format)
35
+ subject.invoke "team:delete", [id]
36
+ end
37
+
38
+ it "invokes team:list_member" do
39
+ api_class.should_receive(:all_member).with(id, {}, format)
40
+ subject.invoke "team:list_member", [id]
41
+ end
42
+
43
+ it "invokes team:member" do
44
+ api_class.should_receive(:member).with(id, user, {}, format)
45
+ subject.invoke "team:member", [id, user]
46
+ end
47
+
48
+ it "invokes team:add_member" do
49
+ api_class.should_receive(:add_member).with(id, user, {}, format)
50
+ subject.invoke "team:add_member", [id, user]
51
+ end
52
+
53
+ it "invokes team:remove_member" do
54
+ api_class.should_receive(:remove_member).with(id, user, {}, format)
55
+ subject.invoke "team:remove_member", [id, user]
56
+ end
57
+
58
+ it "invokes team:list_repo" do
59
+ api_class.should_receive(:all_repo).with(id, {}, format)
60
+ subject.invoke "team:list_repo", [id]
61
+ end
62
+
63
+ it "invokes team:repo" do
64
+ api_class.should_receive(:repo).with(id, user, repo, {}, format)
65
+ subject.invoke "team:repo", [id, user, repo]
66
+ end
67
+
68
+ it "invokes team:add_repo" do
69
+ api_class.should_receive(:add_repo).with(id, user, repo, {}, format)
70
+ subject.invoke "team:add_repo", [id, user, repo]
71
+ end
72
+
73
+ it "invokes team:remove_repo" do
74
+ api_class.should_receive(:remove_repo).with(id, user, repo, {}, format)
75
+ subject.invoke "team:remove_repo", [id, user, repo]
76
+ end
77
+ end
@@ -0,0 +1,30 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe GithubCLI::Commands::Users do
6
+ let(:format) { 'table' }
7
+ let(:user) { 'peter-murach' }
8
+ let(:name) { 'github_cli' }
9
+ let(:api_class) { GithubCLI::User }
10
+
11
+ it "invokes user:list" do
12
+ api_class.should_receive(:all).with({}, format)
13
+ subject.invoke "user:list", []
14
+ end
15
+
16
+ it "invokes user:get" do
17
+ api_class.should_receive(:get).with({}, format)
18
+ subject.invoke "user:get", []
19
+ end
20
+
21
+ it "invokes user:get" do
22
+ api_class.should_receive(:get).with({'user' => user}, format)
23
+ subject.invoke "user:get", [], :user => user
24
+ end
25
+
26
+ it "invokes user:update --name" do
27
+ api_class.should_receive(:update).with({'name' => name}, format)
28
+ subject.invoke "user:update", [], :name => name
29
+ end
30
+ 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.5
4
+ version: 0.5.6
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-03-30 00:00:00.000000000Z
12
+ date: 2013-04-01 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: github_api
16
- requirement: &2156305200 !ruby/object:Gem::Requirement
16
+ requirement: &2153408520 !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: *2156305200
24
+ version_requirements: *2153408520
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &2156304760 !ruby/object:Gem::Requirement
27
+ requirement: &2153408000 !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: *2156304760
35
+ version_requirements: *2153408000
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: aruba
38
- requirement: &2156304140 !ruby/object:Gem::Requirement
38
+ requirement: &2153407340 !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: *2156304140
46
+ version_requirements: *2153407340
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
- requirement: &2156303440 !ruby/object:Gem::Requirement
49
+ requirement: &2153406720 !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: *2156303440
57
+ version_requirements: *2153406720
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: communist
60
- requirement: &2156302700 !ruby/object:Gem::Requirement
60
+ requirement: &2153405940 !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: *2156302700
68
+ version_requirements: *2153405940
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: ronn
71
- requirement: &2156301940 !ruby/object:Gem::Requirement
71
+ requirement: &2153405400 !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: *2156301940
79
+ version_requirements: *2153405400
80
80
  description: CLI-based access to GitHub API v3
81
81
  email:
82
82
  - ''
@@ -273,6 +273,7 @@ files:
273
273
  - spec/github_cli/commands/events_spec.rb
274
274
  - spec/github_cli/commands/followers_spec.rb
275
275
  - spec/github_cli/commands/gists_spec.rb
276
+ - spec/github_cli/commands/issues_spec.rb
276
277
  - spec/github_cli/commands/keys_spec.rb
277
278
  - spec/github_cli/commands/labels_spec.rb
278
279
  - spec/github_cli/commands/milestones_spec.rb
@@ -281,7 +282,9 @@ files:
281
282
  - spec/github_cli/commands/repositories_spec.rb
282
283
  - spec/github_cli/commands/starring_spec.rb
283
284
  - spec/github_cli/commands/tags_spec.rb
285
+ - spec/github_cli/commands/teams_spec.rb
284
286
  - spec/github_cli/commands/trees_spec.rb
287
+ - spec/github_cli/commands/users_spec.rb
285
288
  - spec/github_cli/commands/watching_spec.rb
286
289
  - spec/github_cli/config_spec.rb
287
290
  - spec/github_cli/helpers_spec.rb
@@ -373,6 +376,7 @@ test_files:
373
376
  - spec/github_cli/commands/events_spec.rb
374
377
  - spec/github_cli/commands/followers_spec.rb
375
378
  - spec/github_cli/commands/gists_spec.rb
379
+ - spec/github_cli/commands/issues_spec.rb
376
380
  - spec/github_cli/commands/keys_spec.rb
377
381
  - spec/github_cli/commands/labels_spec.rb
378
382
  - spec/github_cli/commands/milestones_spec.rb
@@ -381,7 +385,9 @@ test_files:
381
385
  - spec/github_cli/commands/repositories_spec.rb
382
386
  - spec/github_cli/commands/starring_spec.rb
383
387
  - spec/github_cli/commands/tags_spec.rb
388
+ - spec/github_cli/commands/teams_spec.rb
384
389
  - spec/github_cli/commands/trees_spec.rb
390
+ - spec/github_cli/commands/users_spec.rb
385
391
  - spec/github_cli/commands/watching_spec.rb
386
392
  - spec/github_cli/config_spec.rb
387
393
  - spec/github_cli/helpers_spec.rb