Class: HolePunch::Cli

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

Instance Method Summary collapse

Constructor Details

#initializeCli

Returns a new instance of Cli.



35
36
37
# File 'lib/holepunch/cli.rb', line 35

def initialize
  Logger.output = LoggerOutputStdio.new
end

Instance Method Details

#execute!(args) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/holepunch/cli.rb', line 39

def execute!(args)
  opts = parse_opts(args)
  Logger.verbose = opts.verbose

  definition = Definition.build(opts.filename, opts.env)

  ec2 = EC2.new({
    access_key_id:     opts.aws_access_key_id,
    secret_access_key: opts.aws_secret_access_key,
    region:            opts.aws_region,
  })
  ec2.apply(definition)

rescue EnvNotDefinedError => e
  Logger.fatal('You have security groups that use an environment, but you did not specify one. See --help')
rescue HolePunchError => e
  Logger.fatal(e.message)
end