docmachine-cli/src/build/cli.cr
Glenn Y. Rolland e59ea9ff44
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
feat: implement and refactor container engine module
This commit introduces a comprehensive implementation and refactoring of
the container engine module. Key enhancements include the addition of
abstract classes and the implementation of container engines.

New features:
- Developed `DockerEngine` and `PodmanEngine` classes, deriving from
  `AbstractContainerEngine` to provide modular functionality.
- Added a CLI `--container-runtime` option, allowing users to select
  their preferred runtime, defaulting to Docker if unspecified.
- Introduced a `container_runtime` property in
  `DocMachine::Build::Config` for improved runtime management.

Refactoring:
- Refactored code to replace hardcoded Docker commands with method calls
  to `AbstractContainerEngine`, promoting code reuse and abstraction.

Signed-off-by: Glenn Y. Rolland <glenux@glenux.net>
2025-03-27 15:37:04 +01:00

61 lines
1.7 KiB
Crystal

require "./config"
module DocMachine::Build
class Cli
def self.add_options(opts, args, parent_config, commands)
config = Config.new(parent_config)
opts.on("build", "Build content and produce HTML & PDF deliverables") do
opts.banner = [
"Usage: #{PROGRAM_NAME} build [options]",
"",
"Main options:"
].join("\n")
opts.separator ""
opts.separator "Builder Options:"
opts.on("-a", "--action ACTION", "Action (watch, build, shell, etc.)") do |action|
config.action = action
end
opts.on("--no-cache", "Disable cache") do |_|
config.enable_cache = false
end
opts.on("-d", "--data-dir DIR", "Content directory") do |dir|
config.data_dir = dir
end
opts.on("-p", "--port PORT", "Set base port to PORT") do |port|
config.port = port.to_i
end
opts.on("-m", "--multiple", "Allow multiple instances per dir" ) do |port|
config.enable_multiple = true
end
opts.on("-r", "--container-runtime RUNTIME", "Container runtime (default docker)") do |runtime|
config.container_runtime = runtime
end
opts.on("-t", "--tty", "Enable TTY mode (needed for shell)") do
config.enable_tty = true
end
opts.on("-i", "--image", "Use specific image:tag (default glenux/docmachine:latest)") do |image_tag|
config.image_tag = image_tag
end
commands << ->() : Nil do
app = DocMachine::Build::Run.new(config)
app.prepare
app.start
app.wait
end
end
end
end
end