Plan save-as file writes in app core

This commit is contained in:
2026-06-02 23:18:19 +02:00
parent 853307697a
commit 8de9dadf1d
6 changed files with 92 additions and 27 deletions

View File

@@ -1345,20 +1345,24 @@ int plan_document_file(int argc, char** argv)
return 2;
}
const auto target = pp::app::make_document_file_target(args.work_directory, args.name);
if (!target) {
print_error("plan-document-file", target.status().message);
const auto plan = pp::app::plan_document_file_save(
args.work_directory,
args.name,
[&args](const std::string&) {
return args.target_exists;
});
if (!plan) {
print_error("plan-document-file", plan.status().message);
return 2;
}
const auto write_decision = pp::app::plan_document_file_write(args.target_exists);
std::cout << "{\"ok\":true,\"command\":\"plan-document-file\""
<< ",\"target\":{\"name\":\"" << json_escape(target.value().name)
<< "\",\"directory\":\"" << json_escape(target.value().directory)
<< "\",\"path\":\"" << json_escape(target.value().path)
<< ",\"target\":{\"name\":\"" << json_escape(plan.value().target.name)
<< "\",\"directory\":\"" << json_escape(plan.value().target.directory)
<< "\",\"path\":\"" << json_escape(plan.value().target.path)
<< "\",\"exists\":" << json_bool(args.target_exists)
<< "},\"decision\":\""
<< document_file_write_decision_name(write_decision)
<< document_file_write_decision_name(plan.value().write_decision)
<< "\"}\n";
return 0;
}