forked from oleander/git-fame-rb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit-fame
executable file
·28 lines (25 loc) · 1.2 KB
/
git-fame
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env ruby -w
require "git_fame"
require "trollop"
sort = ["name", "commits", "loc", "files"]
opts = Trollop::options do
version "git-fame #{GitFame::VERSION} (c) 2012 Linus Oleander"
opt :repository, "What git repository should be used?", default: "."
opt :sort, "What should the printed table be sorted by? #{sort.join(", ")}", default: "loc", type: String
opt :progressbar, "Show progressbar during calculation", default: 1, type: Integer
opt :whitespace, "Ignore whitespace changes", default: false
opt :bytype, "Group line counts by file extension (i.e. .rb, .erb, .yml)", default: false
opt :include, "Paths to include in git ls-files", default: "", type: String
opt :exclude, "Paths to exclude (comma separated)", default: "", type: String
end
Trollop::die :repository, "is not a git repository" unless GitFame::Base.git_repository?(opts[:repository])
Trollop::die :sort, "must be one of the following; #{sort.join(", ")}" unless sort.include?(opts[:sort])
GitFame::Base.new({
repository: opts[:repository],
progressbar: opts[:progressbar] == 1,
sort: opts[:sort],
whitespace: opts[:whitespace],
bytype: opts[:bytype],
include: opts[:include],
exclude: opts[:exclude]
}).pretty_puts