#include <iostream>
#include <string>
#include <map>

using namespace std;

int main(int argc, char* argv[])
{
        if(argc == 1){
                cout << "Usage: add_entry [OPTIONS]" << endl;
		cout << "OPTIONS: -t title" << endl;
		cout << "         -i id" << endl;
        	cout << "         -p path to archive" << endl;
        	cout << "         -v version" << endl;
                return 0;
        }

	string PATH;
	string TITLE;
	string ID;

	string arg[argc];
	for(int i = 0; i < argc; i++)
		arg[i] = argv[i];

	for(int i = 0; i < argc; i++)
	{
		if(arg[i] == "-t")
			TITLE = arg[i+1];
		if(arg[i] == "-i")
			ID = arg[i+1];
		if(arg[i] == "-p")
			PATH = arg[i+1];
		if(arg[i] == "-v")
		{	
			cout << "Version 0.0.2" << endl;
			return 0;
		}
	}

	cout << "Aktueller Datensatz:" << endl;
	cout << "PATH: " << PATH << endl;
	cout << "TITEL: " << TITLE << endl;
	cout << "ID: " << ID << endl;

	FILE *aFile;
	
	const char* cPATH = PATH.c_str();
	aFile = fopen (cPATH,"a+");
	if (aFile == NULL) 
                cout << "Error: Kann " << cPATH << " nicht oeffnen.\n" << endl;
        else 
        {
		const char* cTITLE = TITLE.c_str();
		const char* cID = ID.c_str();
                //Neuen Timer Abspeichern
                fputs (cTITLE,aFile);
                fputs ("|",aFile);
                fputs (cID,aFile);
                fputs ("\n",aFile);
	}
}
