diff --git a/.gitignore b/.gitignore index c6127b3..af105f8 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,7 @@ modules.order Module.symvers Mkfile.old dkms.conf + +.vscode/ +bin/ +tt.conf diff --git a/src/project.cpp b/src/project.cpp index 67197bd..11edbd9 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -135,7 +135,7 @@ void ProjectList::load(std::string file_name, bool ignore_worktimes){ // check for I/O version number in tracking file, toggle legacy mode depending on it if(io_ver_num < io_version_number){ std::cout << "Reading file in legacy mode." << std::endl; - std::cout << "Support for files from tt v.<=1.3.0 will be dropped in the future." << std::endl; + std::cout << "Support for files from tt v.<=1.2.0 will be dropped in the future." << std::endl; std::cout << "Consider converting it using 'convert -'" << std::endl; std::cout << std::endl; diff --git a/src/tt.h b/src/tt.h index fd0a45a..1e1e1f2 100644 --- a/src/tt.h +++ b/src/tt.h @@ -3,8 +3,8 @@ #include -#define TT_VERSION 1.3.0 -#define TT_IO_VERSION 130 +#define TT_VERSION 1.2.0 +#define TT_IO_VERSION 120 // global variables: extern std::string user_name; diff --git a/src/ui.cpp b/src/ui.cpp index 27efd5e..adca560 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -29,6 +29,7 @@ std::string command_names[num_commands]={ "ls", "start", "save", + "load", "version" }; @@ -180,6 +181,12 @@ void parse_input(std::string input, ProjectList *proj_list){ } }else if (command == "save"){ command_save(proj_list); + }else if (command == "load"){ + if(command_end == std::string::npos){ + std::cout << "load: please specify tracking file to load (format: yyyy-mm)" << std::endl; + }else{ + command_load(argument,proj_list); + } }else if (command == "version"){ command_version(); } @@ -568,7 +575,7 @@ void command_report(std::string date_str, ProjectList* proj_list){ if(date_str.length() == 0){ // report for current month - std::string date = get_date(); + std::string date = proj_list->month; //get_date(); std::cout << "Report for " << user_name << ", month: " << date << std::endl << std::endl; for (int i=0; inum_projects; i++){ @@ -621,6 +628,23 @@ void command_save(ProjectList *proj_list){ std::cout << "Tracking data saved to file " << file_name << std::endl; } +// discard current project list and load from file +void command_load(std::string date_str, ProjectList* proj_list){ + date_str = trim(date_str); + std::string file_name = tracking_dir+"/"+date_str; + + // clear project list and load new one + proj_list->projects.clear(); + proj_list->num_projects=0; + proj_list->month=date_str; + proj_list->load(file_name); + + // reset autocomplete + autocomplete_names.clear(); + init_autocomplete(proj_list); + std::cout << "Loaded project data for month " << proj_list->month << std::endl << std::endl; +} + // print version number void command_version(){ std::cout << "tt v." << STRING(TT_VERSION) << std::endl; diff --git a/src/ui.h b/src/ui.h index 5fde932..a238a82 100644 --- a/src/ui.h +++ b/src/ui.h @@ -5,7 +5,7 @@ #include #include "project.h" -const int num_commands=13; +const int num_commands=14; extern std::string command_names[num_commands]; extern std::vector autocomplete_names; char **tt_name_completion(const char* text, int start, int end); @@ -30,5 +30,6 @@ void command_at(std::string input, int wtime, ProjectList *proj_list); void command_rt(std::string input, int wtime, ProjectList *proj_list); void command_report(std::string date_str, ProjectList *proj_list); void command_save(ProjectList *proj_list); +void command_load(std::string date_str, ProjectList *proj_list); void command_version(); #endif