]>
Commit | Line | Data |
---|---|---|
9fb2a970 ÆAB |
1 | #include "test-tool.h" |
2 | #include "test-tool-utils.h" | |
3 | #include "cache.h" | |
4 | #include "parse-options.h" | |
5 | #include "submodule.h" | |
6 | ||
7 | #define TEST_TOOL_IS_ACTIVE_USAGE \ | |
8 | "test-tool submodule is-active <name>" | |
9 | static const char *submodule_is_active_usage[] = { | |
10 | TEST_TOOL_IS_ACTIVE_USAGE, | |
11 | NULL | |
12 | }; | |
13 | ||
14 | static const char *submodule_usage[] = { | |
15 | TEST_TOOL_IS_ACTIVE_USAGE, | |
16 | NULL | |
17 | }; | |
18 | ||
19 | static int cmd__submodule_is_active(int argc, const char **argv) | |
20 | { | |
21 | struct option options[] = { | |
22 | OPT_END() | |
23 | }; | |
24 | argc = parse_options(argc, argv, "test-tools", options, | |
25 | submodule_is_active_usage, 0); | |
26 | if (argc != 1) | |
27 | usage_with_options(submodule_is_active_usage, options); | |
28 | ||
29 | setup_git_directory(); | |
30 | ||
31 | return !is_submodule_active(the_repository, argv[0]); | |
32 | } | |
33 | ||
34 | static struct test_cmd cmds[] = { | |
35 | { "is-active", cmd__submodule_is_active }, | |
36 | }; | |
37 | ||
38 | int cmd__submodule(int argc, const char **argv) | |
39 | { | |
40 | struct option options[] = { | |
41 | OPT_END() | |
42 | }; | |
43 | size_t i; | |
44 | ||
45 | argc = parse_options(argc, argv, "test-tools", options, submodule_usage, | |
46 | PARSE_OPT_STOP_AT_NON_OPTION); | |
47 | if (argc < 1) | |
48 | usage_with_options(submodule_usage, options); | |
49 | ||
50 | for (i = 0; i < ARRAY_SIZE(cmds); i++) | |
51 | if (!strcmp(cmds[i].name, argv[0])) | |
52 | return cmds[i].fn(argc, argv); | |
53 | ||
54 | usage_msg_optf("unknown subcommand '%s'", submodule_usage, options, | |
55 | argv[0]); | |
56 | ||
57 | return 0; | |
58 | } |