Commit | Line | Data |
---|---|---|
e30b2feb | 1 | #include "git-compat-util.h" |
abca927d | 2 | #include "credential.h" |
e30b2feb | 3 | #include "builtin.h" |
abca927d JK |
4 | |
5 | static const char usage_msg[] = | |
e30b2feb | 6 | "git credential [fill|approve|reject]"; |
abca927d | 7 | |
e30b2feb | 8 | int cmd_credential(int argc, const char **argv, const char *prefix) |
abca927d JK |
9 | { |
10 | const char *op; | |
11 | struct credential c = CREDENTIAL_INIT; | |
abca927d JK |
12 | |
13 | op = argv[1]; | |
14 | if (!op) | |
15 | usage(usage_msg); | |
abca927d JK |
16 | |
17 | if (credential_read(&c, stdin) < 0) | |
18 | die("unable to read credential from stdin"); | |
19 | ||
20 | if (!strcmp(op, "fill")) { | |
21 | credential_fill(&c); | |
22 | if (c.username) | |
23 | printf("username=%s\n", c.username); | |
24 | if (c.password) | |
25 | printf("password=%s\n", c.password); | |
e30b2feb | 26 | } else if (!strcmp(op, "approve")) { |
abca927d | 27 | credential_approve(&c); |
e30b2feb | 28 | } else if (!strcmp(op, "reject")) { |
abca927d | 29 | credential_reject(&c); |
e30b2feb | 30 | } else { |
abca927d | 31 | usage(usage_msg); |
e30b2feb | 32 | } |
abca927d JK |
33 | return 0; |
34 | } |