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



247
248
249
# File 'lib/git_tools/branches/cleaner.rb', line 247

def self.skip_prompted
  @@skip_prompted
end

.skip_prompted=(value) ⇒ Object



251
252
253
# File 'lib/git_tools/branches/cleaner.rb', line 251

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

.test_mode=(value) ⇒ Object



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

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

Instance Method Details

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



255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'lib/git_tools/branches/cleaner.rb', line 255

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