mirror of
https://github.com/michaeldv/pit.git
synced 2025-12-11 08:53:01 +00:00
Added expand_path() and perish()
This commit is contained in:
24
src/pit.c
24
src/pit.c
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user