35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/linecounter/cli.rb', line 35
def build_parser(options)
OptionParser.new do |o|
o.banner = "Usage: linecounter [options]"
o.separator ""
o.separator "Options:"
o.on("--top N", Integer, "Show top N rows (default: 20).") { |v| options[:top] = v }
o.on("--since STR", String, "Limit churn to commits since date. Supports git-parseable dates in YYYY-MM-DD (e.g., '2025-01-01'), other git-parseable strings (e.g., 'last friday'), and relative forms: 'N.days.ago', 'N.weeks.ago', 'N.hours.ago', 'N.months.ago', 'N.years.ago', plus 'today'/'yesterday'.") { |v| options[:since] = v }
o.on("--min-loc N", Integer, "Exclude files below N non-empty lines (default: 20).") { |v| options[:min_loc] = v }
o.on("--repo PATH", String, "Path to a git repo to scan (default: current directory).") { |v| options[:repo] = v }
o.on("--json", "Output JSON instead of text.") { options[:json] = true }
o.on("--show-branch-count", "Show per-branch keyword breakdown under each file.") { options[:show_branch_count] = true }
o.on("--show-structure-overview", "Show a summary of class structure counts across all files, including avg_loc_per_item (avg statement lines per item).") { options[:show_structure_overview] = true }
o.on("--show-interaction-overview", "Alias for --show-structure-overview.") { options[:show_structure_overview] = true }
o.on("--detailed-structure", "Show overall structure averages (avg lines per item) for each regex item across all files.") { options[:show_detailed_structure] = true }
o.on("-h", "--help", "Show this help.") { puts o; exit }
o.separator ""
o.separator "Examples:"
o.separator " linecounter"
o.separator " linecounter --repo /path/to/repo"
o.separator " linecounter --repo /path/to/repo --top 50"
o.separator " linecounter --repo /path/to/repo --since 2025-01-01"
o.separator " linecounter --repo /path/to/repo --since 2.weeks.ago"
o.separator " linecounter --repo /path/to/repo --min-loc 50"
o.separator " linecounter --repo /path/to/repo --show-branch-count"
o.separator " linecounter --repo /path/to/repo --show-structure-overview"
o.separator " linecounter --repo /path/to/repo --detailed-structure"
o.separator " linecounter --repo /path/to/repo --json"
o.separator " linecounter --repo /path/to/repo --top 30 --since 3.months.ago"
end
end
|