Class: AppMap::Command::AgentSetup::Init

Inherits:
InitStruct
  • Object
show all
Defined in:
lib/appmap/command/agent_setup/init.rb

Instance Attribute Summary

Attributes inherited from InitStruct

#config_file

Instance Method Summary collapse

Instance Method Details

#performObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/appmap/command/agent_setup/init.rb', line 13

def perform
  if File.exist?(config_file)
    puts AppMap::Util.color(%(The AppMap config file #{config_file} already exists.), :magenta)
    return
  end

  ensure_directory_exists

  config = {
    'name' => Service::Guesser.guess_name,
    'packages' => Service::Guesser.guess_paths.map { |path| { 'path' => path } }
  }
  content = YAML.dump(config).gsub("---\n", '')

  File.write(config_file, content)
  puts AppMap::Util.color(
    %(The following AppMap config file #{config_file} has been created:),
    :green
  )
  puts content
end