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
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/hako/cli.rb', line 168 def parse!(argv) @dry_run = false @containers = [] @env = {} @verbose = false @no_wait = false parser.parse!(argv) @definition_path = argv.shift @argv = argv if @definition_path.nil? || @argv.empty? puts parser.help exit 1 end end |
#parser ⇒ Object
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/hako/cli.rb', line 184 def parser @parser ||= OptionParser.new do |opts| opts. = 'hako oneshot [OPTIONS] FILE COMMAND ARG...' opts.version = VERSION opts.on('-t', '--tag=TAG', 'Specify tag') { |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('--no-wait', 'Run Docker container in background and return task information depending on scheduler (experimental)') { @no_wait = 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
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/hako/cli.rb', line 150 def run(argv) parse!(argv) require 'hako/application' require 'hako/commander' if @verbose Hako.logger.level = Logger::DEBUG end = if @dry_run { expand_variables: false, ask_keys: true } else {} end Commander.new(Application.new(@definition_path, )).oneshot(@argv, tag: @tag, containers: @containers, env: @env, dry_run: @dry_run, no_wait: @no_wait) end |