11#include "flutter/fml/command_line.h"
12#include "flutter/fml/file.h"
13#include "flutter/fml/logging.h"
14#include "flutter/fml/mapping.h"
15#include "inja/inja.hpp"
20 std::string input_path;
21 std::string output_path;
23 if (!command_line.
GetOptionValue(
"templater-input", &input_path)) {
25 <<
"Input template path not specified. Use --templater-input.";
28 if (!command_line.
GetOptionValue(
"templater-output", &output_path)) {
30 <<
"Input template path not specified. Use --templater-output.";
36 FML_LOG(
ERROR) <<
"Could not open input file: " << input_path;
40 nlohmann::json arguments;
41 for (
const auto& option : command_line.
options()) {
42 arguments[option.name] = option.value;
44 inja::Environment
env;
45 auto rendered_template =
env.render(
46 std::string_view{
reinterpret_cast<const char*
>(input->GetMapping()),
50 reinterpret_cast<const uint8_t*
>(rendered_template.data()),
51 rendered_template.size()};
56 if (!current_dir.is_valid()) {
61 FML_LOG(
ERROR) <<
"Could not write output to path: " << output_path;
69int main(
int argc,
char const* argv[]) {
const std::vector< Option > & options() const
bool GetOptionValue(std::string_view name, std::string *value) const
static std::unique_ptr< FileMapping > CreateReadOnly(const std::string &path)
#define FML_LOG(severity)
bool TemplaterMain(const fml::CommandLine &command_line)
CommandLine CommandLineFromArgcArgv(int argc, const char *const *argv)
bool WriteAtomically(const fml::UniqueFD &base_directory, const char *file_name, const Mapping &mapping)
fml::UniqueFD OpenDirectory(const char *path, bool create_if_necessary, FilePermission permission)