Class: Immunio::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/immunio/cli.rb

Instance Method Summary collapse

Instance Method Details

#initObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/immunio/cli.rb', line 13

def init
  if File.exist?(config_file) && File.read(config_file) =~ /key:\s+\w+|secret:\s+\w+/
    say 'Immunio already initialized.', :green
    Kernel.exit 0
  end

  key    = options[:key]    || ask('Enter the key generated for your app in Immunio:')
  secret = options[:secret] || ask('Enter the secret generated for your app in Immunio:')

  FileUtils.mkdir_p(File.dirname(config_file))

  File.open(config_file, 'a') do |f|
    f.puts "key: #{key}"
    f.puts "secret: #{secret}"
  end

  say "Credentials written to #{config_file}", :green
end