docmachine-cli/src/build/cli.cr

54 lines
1.3 KiB
Crystal
Raw Normal View History

2023-03-25 20:40:52 +01:00
require "./config"
module DocMachine::Build
2023-03-25 20:40:52 +01:00
class Cli
2023-03-27 16:01:20 +02:00
def self.add_options(opts, args, parent_config, commands)
2023-03-25 20:40:52 +01:00
config = Config.new(parent_config)
opts.on("build", "Build content and produce HTML & PDF deliverables") do
2023-03-25 20:40:52 +01:00
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
2023-03-25 20:40:52 +01:00
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
2023-03-25 20:40:52 +01:00
end
opts.on("-m", "--multiple", "Allow multiple instances per dir" ) do |port|
config.enable_multiple = true
end
2023-03-25 20:40:52 +01:00
opts.on("-t", "--tty", "Enable TTY mode (needed for shell)") do
config.enable_tty = true
end
2023-03-26 11:41:40 +02:00
2023-03-27 16:01:20 +02:00
commands << ->() : Nil do
app = DocMachine::Build::Run.new(config)
2023-03-26 11:41:40 +02:00
app.prepare
app.start
app.wait
end
2023-03-25 20:40:52 +01:00
end
2023-03-26 11:41:40 +02:00
2023-03-25 20:40:52 +01:00
end
end
end