Class: Splunk::Pickaxe::CLI

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

Instance Method Summary collapse

Instance Method Details

#initObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/splunk/pickaxe/cli.rb', line 12

def init
  puts 'Creating Splunk Object directories...'
  [
    Alerts::DIR,
    Dashboards::DIR,
    EventTypes::DIR,
    Reports::DIR,
    Tags::DIR,
    FieldExtractions::DIR
  ].each do |dir|
    Dir.mkdir dir unless Dir.exist? dir
  end

  puts 'Writing Gemfile ...'
  File.open('Gemfile', 'w') do |f|
    f.puts 'source "https://rubygems.org"'
    f.puts
    f.puts 'gem "splunk-pickaxe"'
  end

  puts 'Writing .pickaxe.yml ...'
  File.open('.pickaxe.yml', 'w') do |f|
    f.puts 'namespace:'
    f.puts '  app: TODO'
    f.puts 'environments:'
    f.puts '  MY_ENV: SPLUNK_API_URL'
    f.puts 'emails:'
    f.puts '  - [email protected]'
  end
end

#sync(environment) ⇒ Object



47
48
49
50
51
52
53
54
55
56
# File 'lib/splunk/pickaxe/cli.rb', line 47

def sync(environment)
  cli = HighLine.new

  user = options[:user] || Etc.getlogin
  password = options[:password] || cli.ask('Password: ') { |o| o.echo = '*' }
  execution_path = options[:repo_path] || Dir.getwd

  pickaxe = Pickaxe.configure environment, user, password, execution_path
  pickaxe.sync_all
end