aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Riehs <tristan.riehs@inria.fr>2026-02-08 11:10:33 +0100
committerTristan Riehs <tristan.riehs@inria.fr>2026-02-08 11:10:33 +0100
commit7e6a9dc817070ad2ca1f0ccf9f84dbdf966e1e00 (patch)
tree73861bbd0a5061272cbbb2b0c6b3172d7b04a0ce
parent421941d3e9d304befcbfa614ce35d34afb64c5f0 (diff)
Finalize wiring for ftag sync
-rw-r--r--src/main.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/src/main.c b/src/main.c
index 13f5eba..230b7ed 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1136,7 +1136,21 @@ static int ftag_sync_is_remote_newer(void)
return get_local_mtime() < get_remote_mtime();
}
-static void ftag_sync_pull(void)
+static void ftag_sync_usage(void)
+{
+ puts("Usage: ftag sync COMMAND");
+}
+
+static void ftag_sync_help(int, char **)
+{
+ ftag_sync_usage();
+ puts("Available commands:");
+ puts(" help print this message");
+ puts(" pull update the local database from the remote");
+ puts(" push update the remote database from the local");
+}
+
+static void ftag_sync_pull(int, char **)
{
if (!ftag_sync_is_remote_newer())
return;
@@ -1163,7 +1177,7 @@ static void ftag_sync_pull(void)
}
}
-static void ftag_sync_push(void)
+static void ftag_sync_push(int, char **)
{
if (!ftag_sync_is_local_newer())
return;
@@ -1196,16 +1210,17 @@ static void ftag_sync_push(void)
static void ftag_sync(int argc, char **argv)
{
- /* TODO: make this a real command
-
- Add a help command. */
- assert(argc >= 1);
- if (strcmp(argv[0], "pull") == 0) {
- ftag_sync_pull();
- }
- else if (strcmp(argv[0], "push") == 0) {
- ftag_sync_push();
+ if (argc == 0) {
+ ftag_sync_usage();
+ exit(EXIT_FAILURE);
}
+ struct ftag_command sync_commands[] = {
+ { .name = "help", .func = ftag_sync_help },
+ { .name = "pull", .func = ftag_sync_pull },
+ { .name = "push", .func = ftag_sync_push }
+ };
+ int sync_command_count = sizeof(sync_commands) / sizeof(struct ftag_command);
+ parse_args(argc, argv, sync_commands, sync_command_count);
}
/* Check that the tag we are trying to create does not exist yet. If this