Plan picked path callbacks in app core
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "app_core/document_export.h"
|
||||
#include "app_core/document_cloud.h"
|
||||
#include "app_core/document_platform_io.h"
|
||||
#include "app_core/document_recording.h"
|
||||
#include "app_core/document_route.h"
|
||||
#include "app_core/document_sharing.h"
|
||||
@@ -165,6 +166,10 @@ struct PlanShareFileArgs {
|
||||
std::string path;
|
||||
};
|
||||
|
||||
struct PlanPickedPathArgs {
|
||||
std::string path;
|
||||
};
|
||||
|
||||
struct SimulateAppSessionArgs {
|
||||
bool has_canvas = true;
|
||||
bool new_document = false;
|
||||
@@ -498,6 +503,18 @@ const char* document_share_action_name(pp::app::DocumentShareAction action) noex
|
||||
return "show-save-required-warning";
|
||||
}
|
||||
|
||||
const char* picked_path_action_name(pp::app::PickedPathAction action) noexcept
|
||||
{
|
||||
switch (action) {
|
||||
case pp::app::PickedPathAction::ignore_empty_path:
|
||||
return "ignore-empty-path";
|
||||
case pp::app::PickedPathAction::invoke_callback:
|
||||
return "invoke-callback";
|
||||
}
|
||||
|
||||
return "ignore-empty-path";
|
||||
}
|
||||
|
||||
pp::foundation::Result<float> parse_float_arg(std::string_view text)
|
||||
{
|
||||
float value = 0.0F;
|
||||
@@ -539,6 +556,7 @@ void print_help()
|
||||
<< " plan-cloud-upload-all [--file-count N] [--no-progress-ui]\n"
|
||||
<< " plan-recording-session [--running] [--frame-count N] [--platform-deletes-recorded-files]\n"
|
||||
<< " plan-share-file [--path FILE]\n"
|
||||
<< " plan-picked-path [--path FILE]\n"
|
||||
<< " load-project --path FILE\n"
|
||||
<< " parse-layout --path FILE\n"
|
||||
<< " record-render [--width N] [--height N] [--exercise-clear]\n"
|
||||
@@ -1909,6 +1927,43 @@ int plan_share_file(int argc, char** argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
pp::foundation::Status parse_plan_picked_path_args(
|
||||
int argc,
|
||||
char** argv,
|
||||
PlanPickedPathArgs& args)
|
||||
{
|
||||
for (int i = 2; i < argc; ++i) {
|
||||
const std::string_view key(argv[i]);
|
||||
if (key == "--path") {
|
||||
if (i + 1 >= argc) {
|
||||
return pp::foundation::Status::invalid_argument("missing value for option");
|
||||
}
|
||||
args.path = argv[++i];
|
||||
} else {
|
||||
return pp::foundation::Status::invalid_argument("unknown option");
|
||||
}
|
||||
}
|
||||
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
int plan_picked_path(int argc, char** argv)
|
||||
{
|
||||
PlanPickedPathArgs args;
|
||||
const auto status = parse_plan_picked_path_args(argc, argv, args);
|
||||
if (!status.ok()) {
|
||||
print_error("plan-picked-path", status.message);
|
||||
return 2;
|
||||
}
|
||||
|
||||
const auto decision = pp::app::plan_picked_path(args.path);
|
||||
std::cout << "{\"ok\":true,\"command\":\"plan-picked-path\""
|
||||
<< ",\"state\":{\"path\":\"" << json_escape(args.path)
|
||||
<< "\"},\"decision\":\"" << picked_path_action_name(decision)
|
||||
<< "\"}\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
pp::foundation::Status parse_plan_export_target_args(
|
||||
int argc,
|
||||
char** argv,
|
||||
@@ -4080,6 +4135,10 @@ int main(int argc, char** argv)
|
||||
return plan_share_file(argc, argv);
|
||||
}
|
||||
|
||||
if (command == "plan-picked-path") {
|
||||
return plan_picked_path(argc, argv);
|
||||
}
|
||||
|
||||
if (command == "load-project") {
|
||||
return load_project(argc, argv);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user