Class: Clin::ShellInteraction::FileConflict

Inherits:
Clin::ShellInteraction show all
Defined in:
lib/clin/shell_interaction/file_conflict.rb

Overview

Handle the file_conflict interaction with the user.

Instance Attribute Summary

Attributes inherited from Clin::ShellInteraction

#shell

Instance Method Summary collapse

Methods inherited from Clin::ShellInteraction

#initialize, #persist!, #persist?, #persist_answer

Constructor Details

This class inherits a constructor from Clin::ShellInteraction

Instance Method Details

#run(filename, default: nil, &block) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/clin/shell_interaction/file_conflict.rb', line 5

def run(filename, default: nil, &block)
  choices = file_conflict_choices
  choices = choices.except(:diff) unless block_given?
  return true if persist?
  result = nil
  while result.nil?
    choice = @shell.choose("Overwrite '#{filename}'?", choices,
                           default: default, allow_initials: true)
    result = handle_choice(choice, filename, &block)
  end
  result
end