diff options
| author | Tristan Riehs <tristan.riehs@inria.fr> | 2025-12-25 18:01:35 +0100 |
|---|---|---|
| committer | Tristan Riehs <tristan.riehs@inria.fr> | 2025-12-25 18:01:35 +0100 |
| commit | 7c0bdcb1378b411f27cb4fcb3473fcf14624aa71 (patch) | |
| tree | d3d07b2883ec9b5bed07802b80d9b2e1d34f6557 | |
| parent | 404cbda9c373a8ca7726e5bc82c79ddf1fb9d987 (diff) | |
Add help option to "ftag file add"
| -rw-r--r-- | src/main.c | 24 |
1 files changed, 21 insertions, 3 deletions
@@ -376,10 +376,25 @@ static void ftag_add_one_file(sqlite3 *db, int *next_id, const char *file) static void ftag_file_add_usage(void) { - fprintf(stderr, "Usage: ftag file add [-i] FILE...\n"); + fprintf(stderr, "Usage: ftag file add [OPTION]... FILE...\n"); } -/* Add new files to the database. */ +static void ftag_file_add_help(void) +{ + printf("ftag file add: add files to the database.\n"); + ftag_file_add_usage(); + printf("Available options:\n"); + printf(" -h print help message\n"); + printf(" -i interactive, ask before adding each file to the database\n"); + printf("Tips:\n"); + printf(" For adding all files in a directory, use\n"); + printf(" ftag file add dir/*\n"); + printf(" For doing it recursively, use\n"); + printf(" find dir -type f -print | xargs ftag file add"); +} + +/* Add new files to the database. If directories are given, every file in the + * directory will be added, does _not_ recurse into subdirectories. */ static void ftag_file_add(int argc, char **argv) { if (argc == 0) { @@ -389,11 +404,14 @@ static void ftag_file_add(int argc, char **argv) sqlite3 *db = NULL; int interactive = 0; int rc; - while (argv[0][0] == '-') { + while ((argc > 0) && (argv[0][0] == '-')) { switch (argv[0][1]) { case 'i': interactive = 1; break; + case 'h': + ftag_file_add_help(); + exit(EXIT_SUCCESS); default: ftag_file_add_usage(); exit(EXIT_FAILURE); |
