Added funko export functionality

This commit is contained in:
Roberto Alsina 2024-06-30 10:49:50 -03:00
parent 6a678944a0
commit adb8ce2667
4 changed files with 39 additions and 4 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@
/.shards/
*.dwarf
tmp/
export/

View File

@ -105,6 +105,31 @@ module Faaso
end
end
class Export
@arguments : Array(String) = [] of String
@options : Commander::Options
def initialize(options, arguments)
@options = options
@arguments = arguments
end
def run
funkos = Funko.from_paths(@arguments)
funkos.each do |funko|
# Create temporary build location
dst_path = Path.new("export", funko.name)
if File.exists? dst_path
puts "Error: #{dst_path} already exists, not exporting #{funko.path}"
next
end
puts "Exporting #{funko.path} to #{dst_path}"
Dir.mkdir_p(dst_path)
funko.prepare_build dst_path
end
end
end
class Down
@arguments : Array(String) = [] of String
@options : Commander::Options

View File

@ -12,10 +12,10 @@ class Funko
# if Nil, it has no template whatsoever
property runtime : (String | Nil)? = nil
# Extra packages shipped with the Docker image
# Extra operating system packages shipped with the runtime's Docker image
property ship_packages : Array(String) = [] of String
# Extra packages used only in the *build* image
# Extra operating system packages used only when *building* the funko
property devel_packages : Array(String) = [] of String
# Where this is located in the filesystem

View File

@ -34,12 +34,21 @@ cli = Commander::Command.new do |cmd|
cmd.commands.add do |command|
command.use = "down"
command.short = "Stop a function"
command.long = "Stop a function in a container"
command.short = "Stop a funko"
command.long = "Stop a funko in a container"
command.run do |options, arguments|
Faaso::Commands::Down.new(options, arguments).run
end
end
cmd.commands.add do |command|
command.use = "export"
command.short = "Export a funko to a directory"
command.long = "Exports a funko as a self-contained directory."
command.run do |options, arguments|
Faaso::Commands::Export.new(options, arguments).run
end
end
end
Commander.run(cli, ARGV)