diff options
| -rw-r--r-- | src/main.c | 89 |
1 files changed, 43 insertions, 46 deletions
@@ -75,7 +75,7 @@ static void assert_db_exists(void) * should be printed to stdout, eventually not with an ending newline. */ static int prompt_yes_no(void) { - printf(" [Y/n]\n"); + puts(" [Y/n]"); fflush(stdout); size_t line_size = 3; char *line = malloc(line_size); @@ -166,9 +166,6 @@ static time_t time_from_str(const char *str) perror("sscanf"); exit(EXIT_FAILURE); } - printf("%s: debug: year is %d\n", __func__, tm.tm_year); - printf("%s: debug: month is %d\n", __func__, tm.tm_mon); - printf("%s: debug: day is %d\n", __func__, tm.tm_mday); tm.tm_year -= 1900; tm.tm_mon -= 1; return mktime(&tm); @@ -202,18 +199,18 @@ static int table_next_id(sqlite3 *db, const char *table) static void ftag_export_help(void) { - printf("Usage: ftag export [OPTION]... ARCHIVE\n"); - printf("Export files from the database to an archive. Files are read from\n"); - printf("standard input, one per line. Files have to be canonical names that\n"); - printf("exist in the database.\n"); + puts("Usage: ftag export [OPTION]... ARCHIVE"); + puts("Export files from the database to an archive. Files are read from"); + puts("standard input, one per line. Files have to be canonical names that"); + puts("exist in the database."); /* TODO: support files outside of the database A file name starting with a slash can be considered as a file to take from the filesystem, not from the database. */ - printf("Available options:\n"); - printf(" -h print this help\n"); - printf(" -n TODO: add user name as a suffix\n"); - printf(" -f TODO: use files' full names\n"); + puts("Available options:"); + puts(" -h print this help"); + puts(" -n TODO: add user name as a suffix"); + puts(" -f TODO: use files' full names"); } static void ftag_export(int argc, char **argv) @@ -308,7 +305,7 @@ static void ftag_init(int, char **) { int rc = mkdir(FTAG_ROOT "/files", 0755); if (rc == -1) { - fprintf(stderr, "mkdir: " FTAG_ROOT "/files: "); + fprintf(stderr, "mkdir: %s/files: ", FTAG_ROOT); perror(""); exit(EXIT_FAILURE); } @@ -482,23 +479,23 @@ static void ftag_add_one_file(sqlite3 *db, int *next_id, const char *file, uint3 static void ftag_file_add_usage(void) { - fprintf(stderr, "Usage: ftag file add [OPTION]... FILE...\n"); + puts("Usage: ftag file add [OPTION]... FILE..."); } static void ftag_file_add_help(void) { ftag_file_add_usage(); - printf("Add files to the database. Non-files arguments are ignored.\n"); - printf("Available options (all options must precede arguments):\n"); - printf(" -f force, do not search for duplicates\n"); - printf(" -h print help message\n"); - printf(" -i interactive, for each file, ask before adding it to the database\n"); - printf("Tips:\n"); - printf(" For adding all files in a directory DIR, use\n"); - printf(" $ ftag file add -i DIR/*\n"); - printf(" For doing it recursively, use\n"); - printf(" $ find DIR -type f -fprint0 /tmp/files\n"); - printf(" $ xargs -0 -a /tmp/files ftag file add -i\n"); + puts("Add files to the database. Non-files arguments are ignored."); + puts("Available options (all options must precede arguments):"); + puts(" -f force, do not search for duplicates"); + puts(" -h print help message"); + puts(" -i interactive, for each file, ask before adding it to the database"); + puts("Tips:"); + puts(" For adding all files in a directory DIR, use"); + puts(" $ ftag file add -i DIR/*"); + puts(" For doing it recursively, use"); + puts(" $ find DIR -type f -fprint0 /tmp/files"); + puts(" $ xargs -0 -a /tmp/files ftag file add -i"); } /* Structure only used by ftad_file_add and get_sums_callback, for building a @@ -637,12 +634,12 @@ step4: static void ftag_file_help(int, char **) { - printf("Usage: ftag file COMMAND [ARG]...\n"); - printf("Available values for COMMAND:\n"); - printf(" add add files to the database\n"); - printf(" help print this help\n"); - printf(" list list files in the database\n"); - printf(" tag add tags to files\n"); + puts("Usage: ftag file COMMAND [ARG]..."); + puts("Available values for COMMAND:"); + puts(" add add files to the database"); + puts(" help print this help"); + puts(" list list files in the database"); + puts(" tag add tags to files"); } static void ftag_file_list(int argc, char **argv) @@ -721,15 +718,15 @@ static void ftag_file(int argc, char **argv) static void ftag_help(int, char **) { - printf("Usage: ftag COMMAND [ARG]...\n"); - printf("Available values for COMMAND:\n"); - printf(" init initialize the database\n"); - printf(" file manage files\n"); - printf(" help print this message\n"); - printf(" query query ftag database\n"); - printf(" tag manage tags\n"); - printf("Some commands also have their own help, try \"ftag COMMAND help\"\n"); - printf("Configuration:\n"); + puts("Usage: ftag COMMAND [ARG]..."); + puts("Available values for COMMAND:"); + puts(" init initialize the database"); + puts(" file manage files"); + puts(" help print this message"); + puts(" query query ftag database"); + puts(" tag manage tags"); + puts("Some commands also have their own help, try \"ftag COMMAND help\""); + puts("Configuration:"); printf(" root %s\n", FTAG_ROOT "/"); printf(" database %s\n", DATABASE_PATH); printf(" file storage %s\n", FTAG_ROOT "/files/"); @@ -737,7 +734,7 @@ static void ftag_help(int, char **) static void ftag_query_usage(void) { - fprintf(stderr, "usage: ftag query [-a DATE] [-b DATE] [-t TAG]...\n"); + puts("usage: ftag query [-a DATE] [-b DATE] [-t TAG]..."); } /* Debugging callback that prints all the output. */ @@ -917,11 +914,11 @@ static void ftag_tag_add(int argc, char **argv) static void ftag_tag_help(int, char **) { - printf("Usage: ftag tag COMMAND [ARG]...\n"); - printf("Available values for COMMAND:\n"); - printf(" add create new tags\n"); - printf(" help print this help\n"); - printf(" list list available tags\n"); + puts("Usage: ftag tag COMMAND [ARG]..."); + puts("Available values for COMMAND:"); + puts(" add create new tags"); + puts(" help print this help"); + puts(" list list available tags"); } static void ftag_tag_list(int argc, char **argv) |
