Class: GitTools::Branches::ActionExecutor

Inherits:
Object
  • Object
show all
Defined in:
lib/git_tools/branches/cleaner.rb

Constant Summary collapse

@@test_mode =
true
@@skip_prompted =
false

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.skip_promptedObject



238
239
240
# File 'lib/git_tools/branches/cleaner.rb', line 238

def self.skip_prompted
  @@skip_prompted
end

.skip_prompted=(value) ⇒ Object



242
243
244
# File 'lib/git_tools/branches/cleaner.rb', line 242

def self.skip_prompted=(value)
  @@skip_prompted = (value == true)
end

.test_mode=(value) ⇒ Object



234
235
236
# File 'lib/git_tools/branches/cleaner.rb', line 234

def self.test_mode=(value)
  @@test_mode = (value == true)
end

Instance Method Details

#execute(command, action_message, confirmation_prompt = nil) ⇒ Object



246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# File 'lib/git_tools/branches/cleaner.rb', line 246

def execute(command, action_message, confirmation_prompt = nil)
  if @@test_mode
    $stderr.puts("#{action_message} -> #{command}")
  else
    if confirmation_prompt
      if @@skip_prompted
        puts "#{action_message} -> skipping prompts" if $VERBOSE
      else
        puts action_message
        puts "#{confirmation_prompt} [y/N]"
        case $stdin.gets.chomp
        when 'y'
          `#{command}`
        end
      end
    else
        puts action_message
      `#{command}`
    end
  end
end