Class: HolePunch::CLI
- Inherits:
-
Thor
- Object
- Thor
- HolePunch::CLI
- Defined in:
- lib/holepunch/cli.rb
Instance Method Summary collapse
- #apply ⇒ Object
-
#initialize(*args) ⇒ CLI
constructor
A new instance of CLI.
- #service(name = nil) ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(*args) ⇒ CLI
Returns a new instance of CLI.
26 27 28 29 |
# File 'lib/holepunch/cli.rb', line 26 def initialize(*args) super Logger.output = LoggerOutputStdio.new end |
Instance Method Details
#apply ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/holepunch/cli.rb', line 46 def apply Logger.fatal("AWS Access Key ID not defined. Use --aws-access-key or AWS_ACCESS_KEY_ID") if [:'aws-access-key'].nil? Logger.fatal("AWS Secret Access Key not defined. Use --aws-secret-access-key or AWS_SECRET_ACCESS_KEY") if [:'aws-secret-access-key'].nil? Logger.fatal("AWS Region not defined. Use --aws-region or AWS_REGION") if [:'aws-region'].nil? Logger.verbose = [:verbose] definition = Definition.build([:file], [:env]) ec2 = EC2.new({ access_key_id: [:'aws-access-key'], secret_access_key: [:'aws-secret-access-key'], region: [:'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.) end |
#service(name = nil) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/holepunch/cli.rb', line 75 def service(name = nil) Logger.verbose = [:verbose] definition = Definition.build([:file], [:env]) if [:list] definition.services.keys.sort.each do |name| puts name end else service = definition.services[name] Logger.fatal("service '#{name}' not found") if service.nil? puts service.groups.sort.join(',') end 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.) end |
#version ⇒ Object
97 98 99 |
# File 'lib/holepunch/cli.rb', line 97 def version puts VERSION end |