Class: Claws::Command::Initialize

Inherits:
Object
  • Object
show all
Defined in:
lib/claws/command/initialize.rb

Class Method Summary collapse

Class Method Details

.execObject



6
7
8
9
10
11
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/claws/command/initialize.rb', line 6

def self.exec
  h = {
    'capistrano' => {
      'home' => nil,
    },
    'ssh' => {
      'user' => nil,
      'identity' => nil,
    },
    'aws' => {
      'access_key_id' => nil,
      'secret_access_key' => nil,
    },
    'ec2' => {
      'fields' => {
        'id' => {
          'width' => 10,
          'title' => 'ID',
        },
        'name' => {
          'width' => 20,
          'title' => 'Name',
        },
        'status' => {
          'width' => 8,
          'title' => 'Status',
        },
        'dns_name' => {
          'width' => 42,
          'title' => 'DNS Name',
        },
        'instance_type' => {
          'width' => 13,
          'title' => 'Instance Type',
        },
        'public_ip_address' => {
          'width' => 16,
          'title' => 'Public IP',
        },
        'private_ip_address' => {
          'width' => 16,
          'title' => 'Private IP',
        },
        'tags' => {
          'width' => 30,
          'title' => 'tags',
        },
      },
    }
  }

  conf = File.join(ENV['HOME'], '.claws.yml')

  if File.exists?(conf)
    puts "Configuration file #{conf} exists!  Either remove or modify contents."
    exit 1
  else
    print "Creating configuration file: #{conf}..."
    File.open(conf, 'w').write(h.to_yaml)
    puts "Complete!\nEnter your access key id and secret access key to access your AWS account."
    exit 0
  end
end