9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/gem_digest/cli.rb', line 9
def self.start
program :name, "gemd"
program :version, GemDigest::VERSION
program :description, "Analyze and categorize gem updates from Gemfile.lock"
command :analyze do |c|
c.syntax = "gemd analyze [options]"
c.summary = "Analyze Gemfile.lock and show available gem updates"
c.description = "Parse Gemfile.lock, fetch latest versions from RubyGems, and categorize updates by semantic versioning"
c.option "--gemfile-lock PATH", String, "Path to Gemfile.lock (default: ./Gemfile.lock)"
c.option "--format FORMAT", String, "Output format: console or markdown (default: console)"
c.option "--output-dir DIR", String, "Output directory for reports (default: ./output)"
c.option "--show-up-to-date", "Show gems that are already up to date"
c.option "--verbose", "Show detailed output"
c.action do |args, options|
options.default(
gemfile_lock: "Gemfile.lock",
format: "console",
output_dir: "output",
show_up_to_date: false,
verbose: false
)
begin
puts "🔍 Analyzing gems..." if options.verbose
analyzer = GemDigest::Analyzer.new(options.gemfile_lock)
gems_data = analyzer.analyze
puts "📊 Categorizing updates..." if options.verbose
categorizer = GemDigest::Categorizer.new
categorized_gems = categorizer.categorize(gems_data)
puts "📝 Generating report..." if options.verbose
reporter_class = case options.format
when "markdown"
GemDigest::Reporters::Markdown
else
GemDigest::Reporters::Console
end
reporter_options = {
output_dir: options.output_dir,
show_up_to_date: options.show_up_to_date,
verbose: options.verbose
}
reporter = reporter_class.new(reporter_options)
reporter.generate_report(categorized_gems)
rescue GemDigest::Error => e
puts "❌ Error: #{e.message}"
exit 1
rescue StandardError => e
puts "❌ Unexpected error: #{e.message}"
puts e.backtrace if options.verbose
exit 1
end
end
end
command :version do |c|
c.syntax = "gemd version"
c.summary = "Show gem-digest version"
c.action do
puts "gem-digest version #{GemDigest::VERSION}"
end
end
default_command :analyze
end
|