GCC Code Coverage Report


src/
File: src/seed/seed_cmd.c
Date: 2026-03-31 17:48:22
Lines:
19/19
100.0%
Functions:
2/2
100.0%
Branches:
3/3
100.0%

Line Branch Exec Source
1 #include <assert.h>
2 #include <glib.h>
3 #include <stdbool.h>
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
7 #include "cmd/cmd.h"
8 #include "seed/seed.h"
9
10 static error_t parse_opt(int key, char* arg, struct argp_state* state);
11
12 struct seed_arguments {
13 struct global_arguments* global;
14 };
15
16 static struct argp_option options[] = {{NULL}};
17
18 static char doc[] = "Uploads and shares the current state of the repository.";
19
20 struct argp argp = {options, parse_opt, "", doc, NULL, NULL, NULL};
21
22 5 static error_t parse_opt(int key,
23 __attribute__((__unused__)) char* arg,
24 __attribute__((__unused__)) struct argp_state* state) {
25 switch (key) {
26 default:
27 5 return ARGP_ERR_UNKNOWN;
28 }
29
30 return 0;
31 }
32
33 1 extern int gittor_seed(struct argp_state* state) {
34 // Set defaults arguments
35 1 struct seed_arguments args = {0};
36
37 // Change the arguments array for just seed
38 1 int argc = state->argc - state->next + 1;
39 1 char** argv = &state->argv[state->next - 1];
40 1 args.global = state->input;
41
42 // Change the command name to gittor seed
43 1 const char name[] = "seed";
44 1 size_t argv0len = strlen(state->name) + sizeof(name) + 1;
45 1 char* argv0 = argv[0];
46 1 argv[0] = malloc(argv0len);
47
1/1
✓ Branch 1 taken 1 times.
1 g_snprintf(argv[0], argv0len, "%s %s", state->name, name);
48
49 // Parse arguments
50
1/1
✓ Branch 1 taken 1 times.
1 int err = argp_parse(&argp, argc, argv, ARGP_NO_EXIT, &argc, &args);
51
52 // Stub output for template
53 1 printf("%s PATH: %s (seed command not yet implemented)\n", argv[0],
54
1/1
✓ Branch 1 taken 1 times.
1 args.global->path);
55
56 // Reset back to global
57 1 free(argv[0]);
58 1 argv[0] = argv0;
59 1 state->next += argc - 1;
60
61 1 return err;
62 }
63