Add command: info
- Add command info. - Update year saving format. (+1900)
This commit is contained in:
parent
d670714dea
commit
8008d9c58d
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "data.h"
|
||||
#include "module.h"
|
||||
#include "modules/info.h"
|
||||
#include "modules/init.h"
|
||||
#include "modules/proj.h"
|
||||
|
||||
|
@ -13,6 +14,8 @@ Module* get_Mod(std::string name) {
|
|||
return init_new();
|
||||
} else if (name == "proj") {
|
||||
return proj_new();
|
||||
} else if (name == "info") {
|
||||
return info_new();
|
||||
}
|
||||
return nullptr;
|
||||
};
|
||||
|
@ -21,6 +24,8 @@ void dispatch_Mod(std::string mod, std::vector<std::string> args) {
|
|||
init_dispatch(args);
|
||||
} else if (mod == "proj") {
|
||||
proj_dispatch(args);
|
||||
} else if (mod == "info") {
|
||||
info_dispatch(args);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
#include "info.h"
|
||||
|
||||
void info_print(info_args args) {
|
||||
std::cout << "-----------------------" << std::endl;
|
||||
std::cout << "Creation Date: " << args.db->creationDate.day << "/"
|
||||
<< args.db->creationDate.month << "/"
|
||||
<< args.db->creationDate.year << std::endl;
|
||||
std::cout << "Last Access Date: " << args.db->creationDate.day << "/"
|
||||
<< args.db->creationDate.month << "/"
|
||||
<< args.db->creationDate.year << std::endl;
|
||||
std::cout << "Projects Number: " << args.db->projects->size() << std::endl;
|
||||
std::cout << "-----------------------" << std::endl;
|
||||
}
|
||||
|
||||
info_mod* info_new() {
|
||||
info_mod* mod = new info_mod{};
|
||||
mod->name = "Info";
|
||||
mod->desc = "Shows information about the skids databse";
|
||||
return mod;
|
||||
}
|
||||
|
||||
void info_dispatch(const std::vector<std::string>& arguments) {
|
||||
info_args args;
|
||||
args.db = new DB();
|
||||
loadDB(*args.db, ".db");
|
||||
info_print(args);
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef MODULE_INFO_H
|
||||
#define MODULE_INFO_H
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "data.h"
|
||||
#include "module.h"
|
||||
|
||||
struct info_args {
|
||||
DB* db;
|
||||
};
|
||||
|
||||
struct info_mod : info_args, Module {};
|
||||
|
||||
info_mod* info_new();
|
||||
void info_print(info_args args);
|
||||
void info_dispatch(const std::vector<std::string>& arguments);
|
||||
#endif
|
|
@ -10,10 +10,10 @@ void init_create(init_args arg) {
|
|||
|
||||
db.creationDate.day = currentTime->tm_mday;
|
||||
db.creationDate.month = currentTime->tm_mon;
|
||||
db.creationDate.year = currentTime->tm_year;
|
||||
db.creationDate.year = currentTime->tm_year + 1900;
|
||||
db.lastAccessTime.day = currentTime->tm_mday;
|
||||
db.lastAccessTime.month = currentTime->tm_mon;
|
||||
db.lastAccessTime.year = currentTime->tm_year;
|
||||
db.lastAccessTime.year = currentTime->tm_year + 1900;
|
||||
|
||||
// Mandatory stuff to stop segmantion fault due to
|
||||
// pointers unintialized.
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
#include "proj.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/uuid/uuid.hpp> // uuid class
|
||||
#include <boost/uuid/uuid_generators.hpp> // generators
|
||||
#include <boost/uuid/uuid_io.hpp> // streaming operators etc.
|
||||
|
||||
#include "../data.h"
|
||||
|
||||
void proj_add(proj_args args) {
|
||||
Project proj;
|
||||
proj.name = args.action_param;
|
||||
|
@ -33,7 +29,7 @@ void proj_add(proj_args args) {
|
|||
|
||||
proj.creationDate.day = currentTime->tm_mday;
|
||||
proj.creationDate.month = currentTime->tm_mon;
|
||||
proj.creationDate.year = currentTime->tm_year;
|
||||
proj.creationDate.year = currentTime->tm_year + 1900;
|
||||
|
||||
(*args.db->projects)[proj.uuid] = proj;
|
||||
writeDB(*args.db, ".db");
|
||||
|
|
Loading…
Reference in New Issue