Class: Hako::CLI::Oneshot
- Inherits:
-
Object
- Object
- Hako::CLI::Oneshot
- Defined in:
- lib/hako/cli.rb
Instance Method Summary collapse
Instance Method Details
#parse!(argv) ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/hako/cli.rb', line 107 def parse!(argv) @tag = 'latest' @dry_run = false @containers = [] @env = {} @verbose = false parser.parse!(argv) @yaml_path = argv.shift @argv = argv if @yaml_path.nil? || @argv.empty? puts parser.help exit 1 end end |
#parser ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/hako/cli.rb', line 123 def parser @parser ||= OptionParser.new do |opts| opts. = 'hako oneshot [OPTIONS] FILE COMMAND ARG...' opts.version = VERSION opts.on('-t', '--tag=TAG', 'Specify tag (default: latest)') { |v| @tag = v } opts.on('-n', '--dry-run', 'Enable dry-run mode') { @dry_run = true } opts.on('-c', '--container=NAME', 'Additional container name to start with the app container') { |v| @containers << v } opts.on('-v', '--verbose', 'Enable verbose logging') { @verbose = true } opts.on('-e', '--env=NAME=VAL', 'Add environment variable') do |arg| k, v = arg.split('=', 2) @env[k] = v end end end |
#run(argv) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/hako/cli.rb', line 95 def run(argv) parse!(argv) require 'hako/application' require 'hako/commander' if @verbose Hako.logger.level = Logger::DEBUG end Commander.new(Application.new(@yaml_path)).oneshot(@argv, tag: @tag, containers: @containers, env: @env, dry_run: @dry_run) end |