Fifth batch for 2.19 cycle
[git/git.git] / help.h
CommitLineData
940208a7
MV
1#ifndef HELP_H
2#define HELP_H
3
3ac68a93
NTND
4#include "string-list.h"
5#include "strbuf.h"
6bb2dc0b 6
940208a7
MV
7struct cmdnames {
8 int alloc;
9 int cnt;
10 struct cmdname {
8af84dad 11 size_t len; /* also used for similarity index in help.c */
940208a7
MV
12 char name[FLEX_ARRAY];
13 } **names;
14};
15
3d78d1f1
MV
16static inline void mput_char(char c, unsigned int num)
17{
18 while(num--)
19 putchar(c);
20}
21
fd5c363d 22extern void list_common_cmds_help(void);
63eae83f 23extern void list_all_cmds_help(void);
1b81d8cb 24extern void list_common_guides_help(void);
e17ca926 25extern void list_config_help(int for_human);
63eae83f 26
6bb2dc0b
NTND
27extern void list_all_main_cmds(struct string_list *list);
28extern void list_all_other_cmds(struct string_list *list);
3c777767
NTND
29extern void list_cmds_by_category(struct string_list *list,
30 const char *category);
6532f374 31extern void list_cmds_by_config(struct string_list *list);
fd5c363d
TF
32extern const char *help_unknown_cmd(const char *cmd);
33extern void load_command_list(const char *prefix,
34 struct cmdnames *main_cmds,
35 struct cmdnames *other_cmds);
36extern void add_cmdname(struct cmdnames *cmds, const char *name, int len);
940208a7 37/* Here we require that excludes is a sorted list. */
fd5c363d
TF
38extern void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes);
39extern int is_in_cmdlist(struct cmdnames *cmds, const char *name);
f4ed0af6 40extern void list_commands(unsigned int colopts, struct cmdnames *main_cmds, struct cmdnames *other_cmds);
940208a7 41
e5618106
VV
42/*
43 * call this to die(), when it is suspected that the user mistyped a
44 * ref to the command, to give suggested "correct" refs.
45 */
46extern void help_unknown_ref(const char *ref, const char *cmd, const char *error);
3ac68a93
NTND
47
48static inline void list_config_item(struct string_list *list,
49 const char *prefix,
50 const char *str)
51{
52 string_list_append_nodup(list, xstrfmt("%s.%s", prefix, str));
53}
54
55#define define_list_config_array(array) \
56void list_config_##array(struct string_list *list, const char *prefix) \
57{ \
58 int i; \
59 for (i = 0; i < ARRAY_SIZE(array); i++) \
60 if (array[i]) \
61 list_config_item(list, prefix, array[i]); \
62} \
63struct string_list
64
65#define define_list_config_array_extra(array, values) \
66void list_config_##array(struct string_list *list, const char *prefix) \
67{ \
68 int i; \
69 static const char *extra[] = values; \
70 for (i = 0; i < ARRAY_SIZE(extra); i++) \
71 list_config_item(list, prefix, extra[i]); \
72 for (i = 0; i < ARRAY_SIZE(array); i++) \
73 if (array[i]) \
74 list_config_item(list, prefix, array[i]); \
75} \
76struct string_list
77
78/* These are actually scattered over many C files */
79void list_config_advices(struct string_list *list, const char *prefix);
80void list_config_color_branch_slots(struct string_list *list, const char *prefix);
81void list_config_color_decorate_slots(struct string_list *list, const char *prefix);
82void list_config_color_diff_slots(struct string_list *list, const char *prefix);
83void list_config_color_grep_slots(struct string_list *list, const char *prefix);
84void list_config_color_interactive_slots(struct string_list *list, const char *prefix);
85void list_config_color_status_slots(struct string_list *list, const char *prefix);
86void list_config_fsck_msg_ids(struct string_list *list, const char *prefix);
87
940208a7 88#endif /* HELP_H */