docmachine-utils/src/write/cli.cr

46 lines
1.1 KiB
Crystal

require "./config"
require "./run"
require "./module"
module DocMachine::Write
class Cli
Log = DocMachine::Write::Log.for("cli")
def self.add_options(opts, args, parent_config, commands)
config = Config.new(parent_config)
opts.on("write", "Write content target for plan (beta)") do
opts.banner = "Usage: #{PROGRAM_NAME} write [options] TARGET"
opts.on("-f", "--force", "Don't ask for confirmation") do
config.force = true
end
opts.on("-t", "--template TEMPLATE", "Use given template") do |template_name|
config.template_name = template_name
end
commands << ->() : Nil do
Log.debug { "before any" }
if args.size < 1
Log.error { "No target given!" }
exit 1
end
config.target_directory = args[0]
Log.debug { "before new" }
app = DocMachine::Write::Run.new(config)
Log.debug { "before prepare" }
app.prepare
Log.debug { "before start" }
app.start
Log.debug { "before wait" }
app.wait
end
end
end
end
end