Module: Hunkify::UI
- Defined in:
- lib/hunkify/ui.rb
Class Method Summary collapse
- .confirm_plan(plan) ⇒ Object
- .print_grouping(commits_data, hunks_by_id) ⇒ Object
- .print_header ⇒ Object
- .print_hunks_overview(hunks) ⇒ Object
- .prompt_edit_commit(commit_data, _index, _total) ⇒ Object
Class Method Details
.confirm_plan(plan) ⇒ Object
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/hunkify/ui.rb', line 65 def confirm_plan(plan) puts Color.bold("📋 Final plan:") plan.each_with_index do |(msg, _), i| puts " #{Color.dim("#{i + 1}.")} #{Color.green(msg)}" end puts print " #{Color.yellow("[Enter]")} Run #{Color.yellow("[q]")} Cancel: " input = $stdin.gets.chomp.downcase exit 0 if input == "q" end |
.print_grouping(commits_data, hunks_by_id) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/hunkify/ui.rb', line 28 def print_grouping(commits_data, hunks_by_id) puts Color.bold("🤖 AI-proposed grouping:") puts commits_data.each_with_index do |c, i| hunk_list = c["hunk_ids"].map { |id| Color.dim("[#{id}]") }.join(" ") files = c["hunk_ids"].map { |id| hunks_by_id[id]&.file_path }.compact.uniq puts " #{Color.bold(Color.blue("Commit #{i + 1}"))} #{hunk_list}" puts " #{Color.green(c["message"])}" puts " #{Color.dim("↳ " + c["reasoning"])}" puts " #{Color.dim("Files: " + files.join(", "))}" puts end end |
.print_header ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/hunkify/ui.rb', line 9 def print_header version = defined?(Hunkify::VERSION) ? Hunkify::VERSION : "" puts puts " #{Color.magenta("▲")} #{Color.bold("hunkify")} #{Color.dim("v#{version}")}" puts " #{Color.dim("─" * 40)}" puts " #{Color.dim("Atomic commits, grouped by Claude.")}" puts end |
.print_hunks_overview(hunks) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/hunkify/ui.rb', line 18 def print_hunks_overview(hunks) puts Color.bold("🔍 #{hunks.size} hunk(s) detected:") hunks.each do |h| added = h.lines.count { |l| l.start_with?("+") } removed = h.lines.count { |l| l.start_with?("-") } puts " #{Color.dim("[#{h.id}]")} #{Color.cyan(h.file_path)} #{Color.green("+#{added}")} #{Color.red("-#{removed}")}" end puts end |
.prompt_edit_commit(commit_data, _index, _total) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/hunkify/ui.rb', line 44 def prompt_edit_commit(commit_data, _index, _total) print " #{Color.yellow("[Enter]")} Confirm #{Color.yellow("[e]")} Edit message #{Color.yellow("[s]")} Skip #{Color.yellow("[q]")} Quit: " input = $stdin.gets.chomp.downcase case input when "" commit_data["message"] when "e" print " ✏️ New message: " new_msg = $stdin.gets.chomp new_msg.empty? ? commit_data["message"] : new_msg when "s" nil when "q" puts Color.red("\n Cancelled.") exit 0 else commit_data["message"] end end |