Skip to content

Commit

Permalink
feat: 支持显示当前任务情况
Browse files Browse the repository at this point in the history
  • Loading branch information
dongwlin committed Sep 26, 2023
1 parent 5cea4cd commit 99153e9
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
39 changes: 37 additions & 2 deletions source/cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,25 @@ int main(int argc, char** argv)
{
continue;
}
std::cout << task.type << " Start" << std::endl;
task_id = MaaPostTask(maa_handle, task.type.c_str(), task.param.to_string().c_str());
std::cout << task.type << " Running..." << std::endl;
auto end_status = MaaWaitTask(maa_handle, task_id);
std::cout << task.type << " End" << std::endl
<< task.type << " Result: " << TaskStatus(end_status) << std::endl;
}
MaaWaitTask(maa_handle, task_id);

if (after_task.enabled && !after_task.type.empty()) {
std::cout << "EndTask Start" << std::endl;
task_id = MaaPostTask(maa_handle, after_task.type.c_str(), after_task.param.to_string().c_str());
MaaWaitTask(maa_handle, task_id);
std::cout << "EndTask Running..." << std::endl;
auto end_status = MaaWaitTask(maa_handle, task_id);
std::cout << "EndTask End" << std::endl
<< "EndTask Result: " << TaskStatus(end_status) << std::endl;
}

std::cout << std::endl << "All Tasks Over" << std::endl;

destroy();

return 0;
Expand Down Expand Up @@ -430,6 +440,31 @@ void save_config(const std::string& adb, const std::string& adb_address, const i
ofs.close();
}

std::string TaskStatus(MaaStatus status) {
std::string task_status;
switch (status) {
case MaaStatus_Invalid:
task_status = "Invalid";
break;
case MaaStatus_Pending:
task_status = "Pending";
break;
case MaaStatus_Running:
task_status = "Running";
break;
case MaaStatus_Success:
task_status = "Success";
break;
case MaaStatus_Failed:
task_status = "Failed";
break;
default:
task_status = "Unkown";
break;
}
return task_status;
}

void mpause()
{
std::ignore = getchar();
Expand Down
2 changes: 2 additions & 0 deletions source/cli/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,6 @@ void save_config(const std::string& adb, const std::string& adb_address, const i

std::string read_adb_config(const std::filesystem::path& cur_dir);

std::string TaskStatus(MaaStatus status);

void mpause();

0 comments on commit 99153e9

Please sign in to comment.