Added expand_path() and perish()

This commit is contained in:
Mike Dvorkin
2010-07-19 19:12:44 -07:00
parent 7d0d3b7d54
commit e3a017b249
6 changed files with 130 additions and 39 deletions

View File

@@ -3,6 +3,7 @@
#include <stdio.h>
#include <time.h>
#include "pit.h"
#include "db.h"
#include "project.h"
#include "task.h"
@@ -17,21 +18,30 @@ static int usage() {
return 1;
}
/*
** Suicide.
*/
void die(char *msg)
{
fprintf(stderr, "pit (fatal): %s\n", msg);
fprintf(stderr, "pit: %s\n", msg);
exit(0);
}
void die_with_errno(char *prefix)
/*
** Forceful death.
*/
void perish(char *prefix)
{
fprintf(stderr, "pit (fatal): %s: ", prefix);
fprintf(stderr, "pit (fatal): ");
if (prefix) {
fprintf(stderr, "%s - ", prefix);
}
perror(NULL);
exit(0);
}
int main(int argc, char *argv[]) {
char *commands[] = { "project", "task", "note", "log" };
char *commands[] = { "project", "task", "note", "log", "init" };
/***
int i;
@@ -46,6 +56,12 @@ int main(int argc, char *argv[]) {
return pit_project(&argv[1]);
} else if (strstr(commands[1], argv[1]) == commands[1]) {
return pit_task(&argv[1]);
} else if (strstr(commands[2], argv[1]) == commands[2]) {
return 1; /* pit_note(&argv[1]); */
} else if (strstr(commands[3], argv[1]) == commands[3]) {
return 1; /* pit_log(&argv[1]); */
} else if (strstr(commands[4], argv[1]) == commands[4]) {
return pit_init(&argv[1]);
}
}
return usage();