Class: Conjur::Command::Init

Inherits:
Conjur::Command show all
Defined in:
lib/conjur/command/init.rb

Class Method Summary collapse

Methods inherited from Conjur::Command

acting_as_option, api, command, display, method_missing, require_arg

Methods included from IdentifierManipulation

#conjur_account, #full_resource_id, #get_kind_and_id_from_args

Class Method Details

.write_file(filename, force, &block) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/conjur/command/init.rb', line 26

def self.write_file(filename, force, &block)
  if File.exists?(filename)
    unless force
      hl = HighLine.new $stdin, $stderr
      force = true if hl.ask("File #{filename} exists. Overwrite (yes/no): ").strip == "yes"
    end
    exit_now! "Not overwriting #{filename}" unless force
  end
  File.open(filename, 'w') do |f|
    yield f
  end
end