jchris-github 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +18 -0
- data/Manifest +17 -0
- data/README +89 -0
- data/bin/github +5 -0
- data/commands/commands.rb +119 -0
- data/commands/helpers.rb +123 -0
- data/github-gem.gemspec +25 -0
- data/lib/github.rb +127 -0
- data/lib/github/command.rb +87 -0
- data/lib/github/extensions.rb +28 -0
- data/lib/github/helper.rb +4 -0
- data/spec/command_spec.rb +66 -0
- data/spec/extensions_spec.rb +36 -0
- data/spec/github_spec.rb +65 -0
- data/spec/helper_spec.rb +212 -0
- data/spec/spec_helper.rb +138 -0
- data/spec/ui_spec.rb +506 -0
- data/spec/windoze_spec.rb +36 -0
- metadata +81 -0
data/LICENSE
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Copyright (c) 2008 Chris Wanstrath
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
5
|
+
the Software without restriction, including without limitation the rights to
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
7
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
8
|
+
subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
15
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
16
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
17
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
18
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
bin/github
|
2
|
+
commands/commands.rb
|
3
|
+
commands/helpers.rb
|
4
|
+
lib/github/extensions.rb
|
5
|
+
lib/github/command.rb
|
6
|
+
lib/github/helper.rb
|
7
|
+
lib/github.rb
|
8
|
+
LICENSE
|
9
|
+
Manifest
|
10
|
+
README
|
11
|
+
spec/command_spec.rb
|
12
|
+
spec/extensions_spec.rb
|
13
|
+
spec/github_spec.rb
|
14
|
+
spec/helper_spec.rb
|
15
|
+
spec/spec_helper.rb
|
16
|
+
spec/ui_spec.rb
|
17
|
+
spec/windoze_spec.rb
|
data/README
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
The GitHub Gem
|
2
|
+
=============
|
3
|
+
|
4
|
+
This gem'll work hand-in-hand with GitHub's API to help you out.
|
5
|
+
|
6
|
+
Catch us in the #github room on freenode if you want to get involved. Or just fork and send a pull request.
|
7
|
+
|
8
|
+
===========
|
9
|
+
Getting started
|
10
|
+
===========
|
11
|
+
|
12
|
+
$ gem install defunkt-github -s http://gems.github.com
|
13
|
+
|
14
|
+
Run it:
|
15
|
+
|
16
|
+
$ github <command> <args>
|
17
|
+
|
18
|
+
|
19
|
+
=============
|
20
|
+
Pulling Upstream Changes
|
21
|
+
=============
|
22
|
+
|
23
|
+
Let's say you just forked `github-gem` on GitHub from defunkt.
|
24
|
+
|
25
|
+
$ git clone git://github.com/YOU/github-gem.git
|
26
|
+
$ cd github-gem
|
27
|
+
$ github pull defunkt
|
28
|
+
|
29
|
+
This will setup a remote and branch for defunkt's repository at master.
|
30
|
+
In this case, a 'defunkt/master' branch.
|
31
|
+
|
32
|
+
If defunkt makes some changes you want, simply `github pull defunkt`. This will
|
33
|
+
leave you in the 'defunkt/master' branch after pulling changes from defunkt's
|
34
|
+
remote. After confirming that defunkt's changes were what you wanted, run `git
|
35
|
+
checkout master` and then `git merge defunkt/master` to merge defunkt's changes
|
36
|
+
into your own master branch. In summary:
|
37
|
+
|
38
|
+
$ github pull defunkt
|
39
|
+
$ git checkout master
|
40
|
+
$ git merge defunkt/master
|
41
|
+
|
42
|
+
If you've already reviewed defunkt's changes and just want to merge them into your
|
43
|
+
master branch, use the `merge` flag:
|
44
|
+
|
45
|
+
$ github pull --merge defunkt
|
46
|
+
|
47
|
+
|
48
|
+
==========
|
49
|
+
Fetching and Evaluation Downstream Changes
|
50
|
+
==========
|
51
|
+
|
52
|
+
If you are the maintainer of a project, you will often need to fetch commits
|
53
|
+
from other developers, evaluate and/or test them, then merge them into the
|
54
|
+
project.
|
55
|
+
|
56
|
+
Let's say you are 'defunkt' and 'mojombo' has forked your 'github-gem' repo,
|
57
|
+
made some changes and issues you a pull request for his 'master' branch.
|
58
|
+
|
59
|
+
From the root of the project, you can do:
|
60
|
+
|
61
|
+
$ github fetch mojombo master
|
62
|
+
|
63
|
+
This will leave you in the 'mojombo/master' branch after fetching his commits.
|
64
|
+
Your local 'mojombo/master' branch is now at the exact same place as mojombo's
|
65
|
+
'master' branch. You can now run tests or evaluate the code for awesomeness.
|
66
|
+
|
67
|
+
If mojombo's changes are good, you'll want to merge your 'master' (or another
|
68
|
+
branch) into those changes so you can retest post-integration:
|
69
|
+
|
70
|
+
$ git merge master
|
71
|
+
|
72
|
+
Test/analyze again and if everything is ok:
|
73
|
+
|
74
|
+
$ git checkout master
|
75
|
+
$ git merge mojombo/master
|
76
|
+
|
77
|
+
The latter command will be a fast-forward merge since you already did the
|
78
|
+
real merge previously.
|
79
|
+
|
80
|
+
|
81
|
+
==========
|
82
|
+
Contributors
|
83
|
+
==========
|
84
|
+
|
85
|
+
- defunkt
|
86
|
+
- maddox
|
87
|
+
- halorgium
|
88
|
+
- kballard
|
89
|
+
- mojombo
|
data/bin/github
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
desc "Open this repo's master branch in a web browser."
|
2
|
+
command :home do |user|
|
3
|
+
if helper.project
|
4
|
+
helper.open helper.homepage_for(user || helper.owner, 'master')
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
desc "Open this repo in a web browser."
|
9
|
+
command :browse do |user, branch|
|
10
|
+
if helper.project
|
11
|
+
# if one arg given, treat it as a branch name
|
12
|
+
# unless it maches user/branch, then split it
|
13
|
+
# if two args given, treat as user branch
|
14
|
+
# if no args given, use defaults
|
15
|
+
user, branch = user.split("/", 2) if branch.nil? unless user.nil?
|
16
|
+
branch = user and user = nil if branch.nil?
|
17
|
+
user ||= helper.branch_user
|
18
|
+
branch ||= helper.branch_name
|
19
|
+
helper.open helper.homepage_for(user, branch)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "Open the network page for this repo in a web browser."
|
24
|
+
command :network do |user|
|
25
|
+
if helper.project
|
26
|
+
user ||= helper.owner
|
27
|
+
helper.open helper.network_page_for(user)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "Info about this project."
|
32
|
+
command :info do
|
33
|
+
puts "== Info for #{helper.project}"
|
34
|
+
puts "You are #{helper.owner}"
|
35
|
+
puts "Currently tracking:"
|
36
|
+
helper.tracking.sort { |(a,),(b,)| a == :origin ? -1 : b == :origin ? 1 : a.to_s <=> b.to_s }.each do |(name,user_or_url)|
|
37
|
+
puts " - #{user_or_url} (as #{name})"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "Track another user's repository."
|
42
|
+
flags :private => "Use git@github.com: instead of git://github.com/."
|
43
|
+
flags :ssh => 'Equivalent to --private'
|
44
|
+
command :track do |remote, user|
|
45
|
+
# track remote user
|
46
|
+
# track remote user/repo
|
47
|
+
# track user
|
48
|
+
# track user/repo
|
49
|
+
user, remote = remote, nil if user.nil?
|
50
|
+
die "Specify a user to track" if user.nil?
|
51
|
+
user, repo = user.split("/", 2)
|
52
|
+
die "Already tracking #{user}" if helper.tracking?(user)
|
53
|
+
repo = @helper.project if repo.nil?
|
54
|
+
repo.chomp!(".git")
|
55
|
+
remote ||= user
|
56
|
+
|
57
|
+
if options[:private] || options[:ssh]
|
58
|
+
git "remote add #{remote} #{helper.private_url_for_user_and_repo(user, repo)}"
|
59
|
+
else
|
60
|
+
git "remote add #{remote} #{helper.public_url_for_user_and_repo(user, repo)}"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
desc "Fetch from a remote to a local branch."
|
65
|
+
command :fetch do |user, branch|
|
66
|
+
die "Specify a user to pull from" if user.nil?
|
67
|
+
user, branch = user.split("/", 2) if branch.nil?
|
68
|
+
branch ||= 'master'
|
69
|
+
GitHub.invoke(:track, user) unless helper.tracking?(user)
|
70
|
+
|
71
|
+
git "fetch #{user} #{branch}:refs/remotes/#{user}/#{branch}"
|
72
|
+
git_exec "checkout -b #{user}/#{branch} refs/remotes/#{user}/#{branch}"
|
73
|
+
end
|
74
|
+
|
75
|
+
desc "Pull from a remote."
|
76
|
+
flags :merge => "Automatically merge remote's changes into your master."
|
77
|
+
command :pull do |user, branch|
|
78
|
+
die "Specify a user to pull from" if user.nil?
|
79
|
+
user, branch = user.split("/", 2) if branch.nil?
|
80
|
+
branch ||= 'master'
|
81
|
+
GitHub.invoke(:track, user) unless helper.tracking?(user)
|
82
|
+
|
83
|
+
if options[:merge]
|
84
|
+
git_exec "pull #{user} #{branch}"
|
85
|
+
else
|
86
|
+
puts "Switching to #{user}/#{branch}"
|
87
|
+
git "checkout #{user}/#{branch}" if git("checkout -b #{user}/#{branch}").error?
|
88
|
+
git_exec "pull #{user} #{branch}"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
desc "Clone a repo."
|
93
|
+
flags :ssh => "Clone using the git@github.com style url."
|
94
|
+
command :clone do |user, repo, dir|
|
95
|
+
die "Specify a user to pull from" if user.nil?
|
96
|
+
if user.include? ?/
|
97
|
+
die "Expected user/repo dir, given extra argument" if dir
|
98
|
+
(user, repo), dir = [user.split('/', 2), repo]
|
99
|
+
end
|
100
|
+
die "Specify a repo to pull from" if repo.nil?
|
101
|
+
|
102
|
+
if options[:ssh]
|
103
|
+
git_exec "clone git@github.com:#{user}/#{repo}.git" + (dir ? " #{dir}" : "")
|
104
|
+
else
|
105
|
+
git_exec "clone git://github.com/#{user}/#{repo}.git" + (dir ? " #{dir}" : "")
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
desc "Generate the text for a pull request."
|
110
|
+
command :'pull-request' do |user, branch|
|
111
|
+
if helper.project
|
112
|
+
die "Specify a user for the pull request" if user.nil?
|
113
|
+
user, branch = user.split('/', 2) if branch.nil?
|
114
|
+
branch ||= 'master'
|
115
|
+
GitHub.invoke(:track, user) unless helper.tracking?(user)
|
116
|
+
|
117
|
+
git_exec "request-pull #{user}/#{branch} origin"
|
118
|
+
end
|
119
|
+
end
|
data/commands/helpers.rb
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
helper :user_and_repo_from do |url|
|
2
|
+
case url
|
3
|
+
when %r|^git://github\.com/([^/]+/[^/]+)$|: $1.split('/')
|
4
|
+
when %r|^(?:ssh://)?(?:git@)?github\.com:([^/]+/[^/]+)$|: $1.split('/')
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
helper :user_and_repo_for do |remote|
|
9
|
+
user_and_repo_from(url_for(remote))
|
10
|
+
end
|
11
|
+
|
12
|
+
helper :user_for do |remote|
|
13
|
+
user_and_repo_for(remote).try.first
|
14
|
+
end
|
15
|
+
|
16
|
+
helper :repo_for do |remote|
|
17
|
+
user_and_repo_for(remote).try.last
|
18
|
+
end
|
19
|
+
|
20
|
+
helper :project do
|
21
|
+
repo = repo_for(:origin)
|
22
|
+
if repo.nil?
|
23
|
+
if url_for(:origin) == ""
|
24
|
+
STDERR.puts "Error: missing remote 'origin'"
|
25
|
+
else
|
26
|
+
STDERR.puts "Error: remote 'origin' is not a github URL"
|
27
|
+
end
|
28
|
+
exit 1
|
29
|
+
end
|
30
|
+
repo.chomp('.git')
|
31
|
+
end
|
32
|
+
|
33
|
+
helper :url_for do |remote|
|
34
|
+
`git config --get remote.#{remote}.url`.chomp
|
35
|
+
end
|
36
|
+
|
37
|
+
helper :remotes do
|
38
|
+
regexp = '^remote\.(.+)\.url$'
|
39
|
+
`git config --get-regexp '#{regexp}'`.split(/\n/).inject({}) do |memo, line|
|
40
|
+
name_string, url = line.split(/ /, 2)
|
41
|
+
m, name = *name_string.match(/#{regexp}/)
|
42
|
+
memo[name.to_sym] = url
|
43
|
+
memo
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
helper :tracking do
|
48
|
+
remotes.inject({}) do |memo, (name, url)|
|
49
|
+
if ur = user_and_repo_from(url)
|
50
|
+
memo[name] = ur.first
|
51
|
+
else
|
52
|
+
memo[name] = url
|
53
|
+
end
|
54
|
+
memo
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
helper :tracking? do |user|
|
59
|
+
tracking.values.include?(user)
|
60
|
+
end
|
61
|
+
|
62
|
+
helper :owner do
|
63
|
+
user_for(:origin)
|
64
|
+
end
|
65
|
+
|
66
|
+
helper :user_and_branch do
|
67
|
+
raw_branch = `git rev-parse --symbolic-full-name HEAD`.chomp.sub(/^refs\/heads\//, '')
|
68
|
+
user, branch = raw_branch.split(/\//, 2)
|
69
|
+
if branch
|
70
|
+
[user, branch]
|
71
|
+
else
|
72
|
+
[owner, user]
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
helper :branch_user do
|
77
|
+
user_and_branch.first
|
78
|
+
end
|
79
|
+
|
80
|
+
helper :branch_name do
|
81
|
+
user_and_branch.last
|
82
|
+
end
|
83
|
+
|
84
|
+
helper :public_url_for_user_and_repo do |user, repo|
|
85
|
+
"git://github.com/#{user}/#{repo}.git"
|
86
|
+
end
|
87
|
+
|
88
|
+
helper :private_url_for_user_and_repo do |user, repo|
|
89
|
+
"git@github.com:#{user}/#{repo}.git"
|
90
|
+
end
|
91
|
+
|
92
|
+
helper :public_url_for do |user|
|
93
|
+
public_url_for_user_and_repo user, project
|
94
|
+
end
|
95
|
+
|
96
|
+
helper :private_url_for do |user|
|
97
|
+
private_url_for_user_and_repo user, project
|
98
|
+
end
|
99
|
+
|
100
|
+
helper :homepage_for do |user, branch|
|
101
|
+
"https://github.com/#{user}/#{project}/tree/#{branch}"
|
102
|
+
end
|
103
|
+
|
104
|
+
helper :network_page_for do |user|
|
105
|
+
"https://github.com/#{user}/#{project}/network"
|
106
|
+
end
|
107
|
+
|
108
|
+
helper :has_launchy? do |blk|
|
109
|
+
begin
|
110
|
+
gem 'launchy'
|
111
|
+
require 'launchy'
|
112
|
+
blk.call
|
113
|
+
rescue Gem::LoadError
|
114
|
+
STDERR.puts "Sorry, you need to install launchy: `gem install launchy`"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
helper :open do |url|
|
119
|
+
has_launchy? proc {
|
120
|
+
Launchy::Browser.new.visit url
|
121
|
+
}
|
122
|
+
end
|
123
|
+
|
data/github-gem.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = %q{github}
|
3
|
+
s.version = "0.1.4"
|
4
|
+
|
5
|
+
s.specification_version = 2 if s.respond_to? :specification_version=
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Chris Wanstrath, Kevin Ballard"]
|
9
|
+
s.date = %q{2008-05-18}
|
10
|
+
s.default_executable = %q{github}
|
11
|
+
s.description = %q{The official `github` command line helper for simplifying your GitHub experience.}
|
12
|
+
s.email = %q{chris@ozmm.org}
|
13
|
+
s.executables = ["github"]
|
14
|
+
s.extra_rdoc_files = ["bin/github", "lib/github/extensions.rb", "lib/github/command.rb", "lib/github/helper.rb", "lib/github.rb", "LICENSE", "README"]
|
15
|
+
s.files = ["bin/github", "commands/commands.rb", "commands/helpers.rb", "lib/github/extensions.rb", "lib/github/command.rb", "lib/github/helper.rb", "lib/github.rb", "LICENSE", "Manifest", "README", "spec/command_spec.rb", "spec/extensions_spec.rb", "spec/github_spec.rb", "spec/helper_spec.rb", "spec/spec_helper.rb", "spec/ui_spec.rb", "spec/windoze_spec.rb", "github-gem.gemspec"]
|
16
|
+
s.has_rdoc = true
|
17
|
+
s.homepage = %q{http://github.com/}
|
18
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Github", "--main", "README"]
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
s.rubyforge_project = %q{github}
|
21
|
+
s.rubygems_version = %q{1.1.1}
|
22
|
+
s.summary = %q{The official `github` command line helper for simplifying your GitHub experience.}
|
23
|
+
|
24
|
+
# s.add_dependency(%q<launchy>, [">= 0"])
|
25
|
+
end
|
data/lib/github.rb
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__)
|
2
|
+
require 'github/extensions'
|
3
|
+
require 'github/command'
|
4
|
+
require 'github/helper'
|
5
|
+
require 'rubygems'
|
6
|
+
|
7
|
+
##
|
8
|
+
# Starting simple.
|
9
|
+
#
|
10
|
+
# $ github <command> <args>
|
11
|
+
#
|
12
|
+
# GitHub.command <command> do |*args|
|
13
|
+
# whatever
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# We'll probably want to use the `choice` gem for concise, tasty DSL
|
17
|
+
# arg parsing action.
|
18
|
+
#
|
19
|
+
|
20
|
+
module GitHub
|
21
|
+
extend self
|
22
|
+
|
23
|
+
BasePath = File.expand_path(File.dirname(__FILE__) + '/..')
|
24
|
+
|
25
|
+
def command(command, &block)
|
26
|
+
debug "Registered `#{command}`"
|
27
|
+
descriptions[command] = @next_description if @next_description
|
28
|
+
@next_description = nil
|
29
|
+
flag_descriptions[command].update @next_flags if @next_flags
|
30
|
+
@next_flags = nil
|
31
|
+
commands[command.to_s] = Command.new(block)
|
32
|
+
end
|
33
|
+
|
34
|
+
def desc(str)
|
35
|
+
@next_description = str
|
36
|
+
end
|
37
|
+
|
38
|
+
def flags(hash)
|
39
|
+
@next_flags ||= {}
|
40
|
+
@next_flags.update hash
|
41
|
+
end
|
42
|
+
|
43
|
+
def helper(command, &block)
|
44
|
+
debug "Helper'd `#{command}`"
|
45
|
+
Helper.send :define_method, command, &block
|
46
|
+
end
|
47
|
+
|
48
|
+
def activate(args)
|
49
|
+
@options = parse_options(args)
|
50
|
+
@debug = @options[:debug]
|
51
|
+
load 'helpers.rb'
|
52
|
+
load 'commands.rb'
|
53
|
+
invoke(args.shift, *args)
|
54
|
+
end
|
55
|
+
|
56
|
+
def invoke(command, *args)
|
57
|
+
block = commands[command.to_s] || commands['default']
|
58
|
+
debug "Invoking `#{command}`"
|
59
|
+
block.call(*args)
|
60
|
+
end
|
61
|
+
|
62
|
+
def commands
|
63
|
+
@commands ||= {}
|
64
|
+
end
|
65
|
+
|
66
|
+
def descriptions
|
67
|
+
@descriptions ||= {}
|
68
|
+
end
|
69
|
+
|
70
|
+
def flag_descriptions
|
71
|
+
@flagdescs ||= Hash.new { |h, k| h[k] = {} }
|
72
|
+
end
|
73
|
+
|
74
|
+
def options
|
75
|
+
@options
|
76
|
+
end
|
77
|
+
|
78
|
+
def parse_options(args)
|
79
|
+
idx = 0
|
80
|
+
args.clone.inject({}) do |memo, arg|
|
81
|
+
case arg
|
82
|
+
when /^--(.+?)=(.*)/
|
83
|
+
args.delete_at(idx)
|
84
|
+
memo.merge($1.to_sym => $2)
|
85
|
+
when /^--(.+)/
|
86
|
+
args.delete_at(idx)
|
87
|
+
memo.merge($1.to_sym => true)
|
88
|
+
when "--"
|
89
|
+
args.delete_at(idx)
|
90
|
+
return memo
|
91
|
+
else
|
92
|
+
idx += 1
|
93
|
+
memo
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def load(file)
|
99
|
+
file[0] == ?/ ? path = file : path = BasePath + "/commands/#{file}"
|
100
|
+
data = File.read(path)
|
101
|
+
GitHub.module_eval data, path
|
102
|
+
end
|
103
|
+
|
104
|
+
def debug(*messages)
|
105
|
+
puts *messages.map { |m| "== #{m}" } if debug?
|
106
|
+
end
|
107
|
+
|
108
|
+
def debug?
|
109
|
+
!!@debug
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
GitHub.command :default do
|
114
|
+
puts "Usage: github command <space separated arguments>", ''
|
115
|
+
puts "Available commands:", ''
|
116
|
+
longest = GitHub.descriptions.map { |d,| d.to_s.size }.max
|
117
|
+
GitHub.descriptions.each do |command, desc|
|
118
|
+
cmdstr = "%-#{longest}s" % command
|
119
|
+
puts " #{cmdstr} => #{desc}"
|
120
|
+
flongest = GitHub.flag_descriptions[command].map { |d,| "--#{d}".size }.max
|
121
|
+
GitHub.flag_descriptions[command].each do |flag, fdesc|
|
122
|
+
flagstr = "#{" " * longest} %-#{flongest}s" % "--#{flag}"
|
123
|
+
puts " #{flagstr}: #{fdesc}"
|
124
|
+
end
|
125
|
+
end
|
126
|
+
puts
|
127
|
+
end
|