Class: DrydockerOptions

Inherits:
Object
  • Object
show all
Defined in:
bin/drydocker

Overview

Command line parser to setup options :name, :command, :image, :entrypoint, :path

Class Method Summary collapse

Class Method Details

.parse(args) ⇒ Object



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
# File 'bin/drydocker', line 9

def self.parse(args)
  options = Drydocker::Config.default_config

  opt_parser = OptionParser.new do |opts|
    opts.banner = 'Usage: drydocker [options]'
    opts.separator ''
    opts.separator 'Specific options:'

    opts.on('-f', '--filename [FILENAME]', 'File of options to load') do |fn|
      options.load(fn)
    end

    opts.on('-n', '--name [NAME]') do |name|
      options[:name] = name
    end

    opts.on('-c', '--command [COMMAND]') do |cmd|
      options[:command] = cmd
    end

    opts.on('-i', '--image [IMAGE]') do |img|
      options[:image] = img
    end

    opts.on('-e', '--entrypoint [ENTRYPOINT]') do |entry|
      options[:entrypoint] = entry
    end

    opts.on('-p', '--path [PATH]') do |path|
      options[:path] = path
    end
  end
  opt_parser.parse!(args)
  options
end