| 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 "devs/devs.h" |
| 9 |
|
|
|
| 10 |
|
|
static error_t parse_opt(int key, char* arg, struct argp_state* state); |
| 11 |
|
|
|
| 12 |
|
|
struct devs_arguments { |
| 13 |
|
|
struct global_arguments* global; |
| 14 |
|
|
}; |
| 15 |
|
|
|
| 16 |
|
|
static struct argp_option options[] = {{NULL}}; |
| 17 |
|
|
|
| 18 |
|
|
static char doc[] = "Manage who can contribute to this repository."; |
| 19 |
|
|
|
| 20 |
|
|
static 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_devs(struct argp_state* state) { |
| 34 |
|
|
// Set defaults for devs arguments |
| 35 |
|
1 |
struct devs_arguments args = {0}; |
| 36 |
|
|
|
| 37 |
|
|
// Prepare arguments array for just devs |
| 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 devs |
| 43 |
|
1 |
const char name[] = "devs"; |
| 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 (devs 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 |
|
|
|