mirror of https://github.com/PatrickLipka/tt.git
Implemented loading and manipulating of old tracking files
This commit is contained in:
parent
e8770bdf39
commit
78cd47992b
|
@ -50,3 +50,7 @@ modules.order
|
|||
Module.symvers
|
||||
Mkfile.old
|
||||
dkms.conf
|
||||
|
||||
.vscode/
|
||||
bin/
|
||||
tt.conf
|
||||
|
|
|
@ -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 <yyyy>-<mm>'" << std::endl;
|
||||
std::cout << std::endl;
|
||||
|
||||
|
|
4
src/tt.h
4
src/tt.h
|
@ -3,8 +3,8 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#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;
|
||||
|
|
26
src/ui.cpp
26
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; i<proj_list->num_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;
|
||||
|
|
3
src/ui.h
3
src/ui.h
|
@ -5,7 +5,7 @@
|
|||
#include <string>
|
||||
#include "project.h"
|
||||
|
||||
const int num_commands=13;
|
||||
const int num_commands=14;
|
||||
extern std::string command_names[num_commands];
|
||||
extern std::vector<std::string> 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
|
||||
|
|
Loading…
Reference in New Issue