Class: RDockerize::Commands::Save

Inherits:
Base
  • Object
show all
Defined in:
lib/r_dockerize/commands/save.rb

Constant Summary

Constants inherited from Base

Base::BASE_KEY

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from RDockerize::Commands::Base

Class Method Details

.run(args) ⇒ Object



6
7
8
# File 'lib/r_dockerize/commands/save.rb', line 6

def self.run(args)
  new(args).run
end

Instance Method Details

#parse(args) ⇒ Object

Raises:

  • (OptionParser::InvalidOption)


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/r_dockerize/commands/save.rb', line 10

def parse(args)
  raise OptionParser::InvalidOption if args.empty?

  exec_opt = lambda do |val, type|
    docker_file?(val)
    save_template(val, type)
    $stdout.puts val
  end

  parser = opt_parser do |opts|
    opts.banner = banner

    opts.on("-d", "--dockerfile=DOCKERFILE_PATH", "# Path to Dockerfile (default)") do |val|
      exec_opt.call(val, :docker)
    end

    opts.on("-c", "--compose=COMPOSEFILE_PATH", "# Path to docker-compose file") do |val|
      exec_opt.call(val, :dco)
    end
  end

  parser.parse!(args)
end

#runObject



34
35
36
# File 'lib/r_dockerize/commands/save.rb', line 34

def run
  $stdout.puts "Template saved!"
end