Class: Sle2Docker::Cli

Inherits:
Thor
  • Object
show all
Defined in:
lib/sle2docker/cli.rb

Instance Method Summary collapse

Instance Method Details

#build(template_name) ⇒ Object



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/sle2docker/cli.rb', line 87

def build(template_name)
  template_dir = Template.template_dir(template_name)
  builder = Builder.new(options)
  container = builder.create(template_dir)
  puts "Container created, it can be imported by running the following command:"
  puts "  docker import - <desired image name> < #{container}"
  puts "\nThen the '#{File.expand_path(File.join(File.dirname(container), '..'))}' directory and all its contents can be removed."
  puts "Note well: KIWI created some of these files while running as root user, " +
       "hence root privileges are required to remove them."
rescue ConfigNotFoundError => e
  $stderr.printf(e.message + "\n")
  exit(1)
rescue TemplateNotFoundError => ex
  $stderr.printf(ex.message + "\n")
  $stderr.printf("To list the available templates use:\n")
  $stderr.printf("  sle2docker list\n")
  exit(1)
end

#listObject



18
19
20
21
# File 'lib/sle2docker/cli.rb', line 18

def list
  puts "Available templates:"
  Template.list.each {|template| puts "  - #{template}"}
end

#show(template_name) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/sle2docker/cli.rb', line 47

def show(template_name)
  template_dir = Template.template_dir(template_name)
  builder = Builder.new(options)
  template_file = builder.find_template_file(template_dir)
  if template_file.end_with?('.erb')
    template = builder.render_template(template_file)
    puts "\n\n"
    puts template
  end
rescue ConfigNotFoundError => e
  $stderr.printf(e.message + "\n")
  exit(1)
rescue TemplateNotFoundError => ex
  $stderr.printf(ex.message + "\n")
  $stderr.printf("To list the available templates use:\n")
  $stderr.printf("  sle2docker list\n")
  exit(1)
end

#versionObject



25
26
27
# File 'lib/sle2docker/cli.rb', line 25

def version
  puts Sle2Docker::VERSION
end