///////////////////////////////////////////////////////////////////////////
| 56 | |
| 57 | //////////////////////////////////////////////////////////////////////////////// |
| 58 | int CmdImportV2::execute(std::string&) { |
| 59 | std::vector<std::map<std::string, std::string>> task_data; |
| 60 | |
| 61 | std::string location = (Context::getContext().data_dir); |
| 62 | File pending_file = File(location + "/pending.data"); |
| 63 | if (pending_file.exists()) { |
| 64 | TF2 pending_tf; |
| 65 | pending_tf.target(pending_file); |
| 66 | auto& pending_tasks = pending_tf.get_tasks(); |
| 67 | task_data.insert(task_data.end(), pending_tasks.begin(), pending_tasks.end()); |
| 68 | } |
| 69 | File completed_file = File(location + "/completed.data"); |
| 70 | if (completed_file.exists()) { |
| 71 | TF2 completed_tf; |
| 72 | completed_tf.target(completed_file); |
| 73 | auto& completed_tasks = completed_tf.get_tasks(); |
| 74 | task_data.insert(task_data.end(), completed_tasks.begin(), completed_tasks.end()); |
| 75 | } |
| 76 | |
| 77 | auto count = import(task_data); |
| 78 | |
| 79 | Context::getContext().footnote( |
| 80 | format("Imported {1} tasks from `*.data` files. You may now delete these files.", count)); |
| 81 | return 0; |
| 82 | } |
| 83 | |
| 84 | //////////////////////////////////////////////////////////////////////////////// |
| 85 | int CmdImportV2::import(const std::vector<std::map<std::string, std::string>>& task_data) { |