version command added

This commit is contained in:
Patrick Lipka 2021-12-17 17:00:22 +01:00
parent d09c657d91
commit ae5319c58c
4 changed files with 19 additions and 3 deletions

View File

@ -250,3 +250,6 @@ Project: Code Project
--- Debugging: 9.26
Total: 24.35
~~~
### `version`
Prints the version number of `tt`

View File

@ -3,6 +3,8 @@
#include <string>
#define TT_VERSION 1.0
// global variables:
extern std::string user_name;
extern std::string tracking_dir;

View File

@ -28,7 +28,8 @@ std::string command_names[num_commands]={
"report",
"ls",
"start",
"save"
"save",
"version"
};
std::vector<std::string> autocomplete_names; // global variable
@ -173,6 +174,8 @@ void parse_input(std::string input, ProjectList *proj_list){
}
}else if (command == "save"){
command_save(proj_list);
}else if (command == "version"){
command_version();
}
}
@ -612,3 +615,10 @@ void command_save(ProjectList *proj_list){
proj_list->save(file_name);
std::cout << "Tracking data saved to file " << file_name << std::endl;
}
// print version number
void command_version(){
std::cout << "tt v." << STRING(TT_VERSION) << std::endl;
std::cout << "Author: Patrick Lipka (patrick.lipka@emea.nec.com)" << std::endl;
std::cout << "tt is free software published under the BSD-2-Clause licence (see. https://opensource.org/licenses/BSD-2-Clause)" << std::endl;
}

View File

@ -5,7 +5,7 @@
#include <string>
#include "project.h"
const int num_commands=12;
const int num_commands=13;
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,4 +30,5 @@ 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_version();
#endif