Move project save commit planning to app core
This commit is contained in:
@@ -414,6 +414,8 @@ struct PlanCanvasProjectSaveTargetArgs {
|
||||
std::string data_directory = "D:/Paint/data";
|
||||
std::string target_path = "D:/Paint/projects/demo.ppi";
|
||||
bool target_exists = false;
|
||||
bool remove_fails = false;
|
||||
bool rename_fails = false;
|
||||
};
|
||||
|
||||
struct PlanCanvasDocumentSnapshotArgs {
|
||||
@@ -2560,7 +2562,7 @@ void print_help()
|
||||
<< " plan-canvas-view-density [--density N] [--bad-float]\n"
|
||||
<< " plan-canvas-view-cursor-mode [--mode N]\n"
|
||||
<< " plan-canvas-cursor [--mode draw|erase|line|camera|grid|copy|cut|fill|mask-free|mask-line|bucket] [--visibility never|small-brush|not-painting|always] [--brush-size N] [--no-brush] [--drawing] [--alt] [--resizing] [--picking] [--bad-size]\n"
|
||||
<< " plan-canvas-project-save-target [--data-dir DIR] [--path FILE] [--target-exists]\n"
|
||||
<< " plan-canvas-project-save-target [--data-dir DIR] [--path FILE] [--target-exists] [--remove-fails] [--rename-fails]\n"
|
||||
<< " plan-grid-operation --kind pick|load|reload|clear|render|commit [--path FILE] [--no-heightmap] [--no-canvas] [--float32] [--float16] [--texture-resolution N] [--samples N]\n"
|
||||
<< " plan-history-operation --kind undo|redo|clear [--undo-count N] [--redo-count N] [--memory-bytes N]\n"
|
||||
<< " plan-main-toolbar --command open|save|undo|redo|clear-history|clear-canvas|message-box|settings [--undo-count N] [--redo-count N] [--memory-bytes N] [--no-canvas]\n"
|
||||
@@ -6091,6 +6093,10 @@ pp::foundation::Status parse_plan_canvas_project_save_target_args(
|
||||
}
|
||||
} else if (key == "--target-exists") {
|
||||
args.target_exists = true;
|
||||
} else if (key == "--remove-fails") {
|
||||
args.remove_fails = true;
|
||||
} else if (key == "--rename-fails") {
|
||||
args.rename_fails = true;
|
||||
} else {
|
||||
return pp::foundation::Status::invalid_argument("unknown option");
|
||||
}
|
||||
@@ -6126,6 +6132,18 @@ int plan_canvas_project_save_target(int argc, char** argv)
|
||||
|
||||
const auto& value = plan.value();
|
||||
const auto& write_value = write_plan.value();
|
||||
const bool target_remove_attempted = write_value.uses_temporary;
|
||||
const bool target_remove_succeeded = target_remove_attempted && !args.remove_fails;
|
||||
const bool temporary_rename_attempted = target_remove_succeeded;
|
||||
const bool temporary_rename_succeeded = temporary_rename_attempted && !args.rename_fails;
|
||||
const auto commit_plan = pp::app::plan_document_canvas_project_save_commit(
|
||||
pp::app::DocumentCanvasProjectSaveCommitInput {
|
||||
.used_temporary = write_value.uses_temporary,
|
||||
.target_remove_attempted = target_remove_attempted,
|
||||
.target_remove_succeeded = target_remove_succeeded,
|
||||
.temporary_rename_attempted = temporary_rename_attempted,
|
||||
.temporary_rename_succeeded = temporary_rename_succeeded,
|
||||
});
|
||||
std::cout << "{\"ok\":true,\"command\":\"plan-canvas-project-save-target\""
|
||||
<< ",\"dataDirectory\":\"" << json_escape(args.data_directory)
|
||||
<< "\",\"targetPath\":\"" << json_escape(value.target_path)
|
||||
@@ -6139,7 +6157,13 @@ int plan_canvas_project_save_target(int argc, char** argv)
|
||||
<< ",\"writePath\":\"" << json_escape(write_value.write_path)
|
||||
<< "\",\"fallbackDirectOnTemporaryOpenFailure\":"
|
||||
<< json_bool(write_value.falls_back_to_direct_on_temporary_open_failure)
|
||||
<< "}"
|
||||
<< "},\"commitPlan\":{\"saved\":" << json_bool(commit_plan.saved)
|
||||
<< ",\"usedTemporary\":" << json_bool(commit_plan.used_temporary)
|
||||
<< ",\"targetRemoved\":" << json_bool(commit_plan.target_removed)
|
||||
<< ",\"temporaryRenamed\":" << json_bool(commit_plan.temporary_renamed)
|
||||
<< ",\"targetMayBeMissing\":" << json_bool(commit_plan.target_may_be_missing)
|
||||
<< ",\"message\":\"" << json_escape(std::string(commit_plan.log_message))
|
||||
<< "\"}"
|
||||
<< "}\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user