Class: Catfish::CLI::Init

Inherits:
Object
  • Object
show all
Defined in:
lib/catfish/cli/init.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, thor) ⇒ Init

Returns a new instance of Init.



6
7
8
9
# File 'lib/catfish/cli/init.rb', line 6

def initialize(options, thor)
  @options = options
  @thor = thor
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/catfish/cli/init.rb', line 4

def options
  @options
end

#thorObject (readonly)

Returns the value of attribute thor.



4
5
6
# File 'lib/catfish/cli/init.rb', line 4

def thor
  @thor
end

Instance Method Details

#runObject



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

def run
  p 'Initializing Catfish repository'

  templates = {
    'Catfishfile.tt' => 'Catfishfile',
    'Vagrantfile.tt' => 'Vagrantfile'
  }

  opts = {
    ssh_username: options['ssh-username'] || '{{YOUR_SSH_USERNAME}}',
    ssh_private_key_path: options['ssh-private-key-path'] || '{{PATH_TO_YOUR_SSH_PRIVATE_KEY}}',
    provisioners: options[:provisioners] || [],
    shell_paths: options['shell-paths'] || ['{{PATH_TO_YOUR_SCRIPT}}']
  }

  templates.each do |src, dst|
    thor.template(src, dst, opts)
  end
  p 'Repository initialized. Remember to:'
  p ' - Check your Vagrantfile and replace any placeholders'
  p ' - Edit your Catfish file and list target servers'
  p ' - Run catfish resolve'
end