mirror of https://github.com/PatrickLipka/tt.git
Added convert command to convert old to new tracking files
This commit is contained in:
parent
78cd47992b
commit
f65930216f
18
src/ui.cpp
18
src/ui.cpp
|
@ -30,6 +30,7 @@ std::string command_names[num_commands]={
|
|||
"start",
|
||||
"save",
|
||||
"load",
|
||||
"convert",
|
||||
"version"
|
||||
};
|
||||
|
||||
|
@ -187,6 +188,13 @@ void parse_input(std::string input, ProjectList *proj_list){
|
|||
}else{
|
||||
command_load(argument,proj_list);
|
||||
}
|
||||
}else if (command == "convert"){
|
||||
if(command_end == std::string::npos){
|
||||
std::cout << "convert: please specify tracking file to convert (format: yyyy-mm)" << std::endl;
|
||||
}else{
|
||||
command_convert(argument);
|
||||
}
|
||||
|
||||
}else if (command == "version"){
|
||||
command_version();
|
||||
}
|
||||
|
@ -645,6 +653,16 @@ void command_load(std::string date_str, ProjectList* proj_list){
|
|||
std::cout << "Loaded project data for month " << proj_list->month << std::endl << std::endl;
|
||||
}
|
||||
|
||||
// convert previous tracking file version to current one
|
||||
void command_convert(std::string date_str){
|
||||
date_str = trim(date_str);
|
||||
ProjectList list(date_str);
|
||||
std::string file_name = tracking_dir+"/"+date_str;
|
||||
list.load(file_name);
|
||||
list.save(file_name);
|
||||
std::cout << "Successfully converted data file" << file_name << 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=14;
|
||||
const int num_commands=15;
|
||||
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);
|
||||
|
@ -31,5 +31,6 @@ 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_convert(std::string date_str);
|
||||
void command_version();
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue