Class: Ruby::Reforge::CLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/ruby/reforge/cli.rb

Instance Method Summary collapse

Instance Method Details

#ai_fixObject



102
103
104
105
# File 'lib/ruby/reforge/cli.rb', line 102

def ai_fix
  say "šŸ¤– AI-Assisted Fix Mode (Experimental)", :green
  say "This feature is coming soon!", :yellow
end

#reportObject



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/ruby/reforge/cli.rb', line 83

def report
  say "šŸ“Š Ruby Reforge - Generating Report", :green
  say ""

  current_version = detect_current_ruby_version
  target_version = options[:target] ? normalize_version(options[:target]) : "3.3.0"

  say "Current Ruby version: #{current_version || 'unknown'}", :yellow
  say "Target Ruby version: #{target_version}", :yellow
  say ""

  say "šŸ” Scanning codebase...", :cyan
  issues = scanner.scan(target_version)

  reporter.report(issues, current_version, target_version)
end

#upgrade(version) ⇒ Object



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
# File 'lib/ruby/reforge/cli.rb', line 16

def upgrade(version)
  say "šŸš€ Ruby Reforge - Upgrading to Ruby #{version}", :green
  say ""

  target_version = normalize_version(version)
  current_version = detect_current_ruby_version

  if current_version == target_version
    say "āœ“ Already on Ruby #{target_version}", :green
    exit 0
  end

  say "Current Ruby version: #{current_version || 'unknown'}", :yellow
  say "Target Ruby version: #{target_version}", :yellow
  say ""

  # Create git branch if in git repo
  if git_integration.available?
    branch_name = options[:branch] || "upgrade/ruby-#{target_version}"
    git_integration.create_branch(branch_name) unless options[:dry_run]
  end

  # Scan for issues
  say "šŸ” Scanning codebase...", :cyan
  issues = scanner.scan(target_version)

  # Generate report
  reporter.report(issues, current_version, target_version)

  if options[:dry_run]
    say "\nšŸ” DRY RUN - No changes made", :yellow
    exit 0
  end

  # Interactive mode
  if options[:interactive]
    prompt = TTY::Prompt.new
    unless prompt.yes?("Proceed with automatic fixes?")
      say "Aborted.", :red
      exit 0
    end
  end

  # Update version files
  say "\nšŸ“ Updating version files...", :cyan
  version_updater.update(target_version)

  # Apply fixes
  say "\nšŸ”§ Applying fixes...", :cyan
  rewriter.rewrite(issues, interactive: options[:interactive])

  # Commit changes
  if git_integration.available? && !options[:dry_run]
    git_integration.commit_version_files
    git_integration.commit_code_changes
  end

  say "\nāœ… Upgrade complete!", :green
  say "\nNext steps:"
  say "  1. Review the changes"
  say "  2. Run your test suite"
  say "  3. Update dependencies: bundle update"
  say "  4. Check for any manual fixes needed"
end