docmachine-utils/src/build/cli.cr

54 lines
1.3 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("-t", "--tty", "Enable TTY mode (needed for shell)") do
config.enable_tty = true
end
commands << ->() : Nil do
app = DocMachine::Build::Run.new(config)
app.prepare
app.start
app.wait
end
end
end
end
end