blob: af073a7a0263e7bdacf6dd01f13235b2a655f360 [file] [log] [blame]
Miklos Vajna940208a2008-07-30 01:16:58 +02001#ifndef HELP_H
2#define HELP_H
3
Nguyễn Thái Ngọc Duy3ac68a92018-05-26 15:55:24 +02004#include "string-list.h"
5#include "strbuf.h"
Nguyễn Thái Ngọc Duy6bb2dc02018-05-20 20:39:59 +02006
Miklos Vajna940208a2008-07-30 01:16:58 +02007struct cmdnames {
8 int alloc;
9 int cnt;
10 struct cmdname {
Johannes Schindelin8af84da2008-08-31 15:50:23 +020011 size_t len; /* also used for similarity index in help.c */
Miklos Vajna940208a2008-07-30 01:16:58 +020012 char name[FLEX_ARRAY];
13 } **names;
14};
15
Miklos Vajna3d78d1f2008-08-02 10:08:38 +020016static inline void mput_char(char c, unsigned int num)
17{
Johannes Schindelin5acea872018-12-11 06:58:10 -080018 while (num--)
Miklos Vajna3d78d1f2008-08-02 10:08:38 +020019 putchar(c);
20}
21
Denton Liu55454422019-04-29 04:28:14 -040022void list_common_cmds_help(void);
Ævar Arnfjörð Bjarmason1ce59012022-02-21 20:38:51 +010023void list_all_cmds_help(int show_external_commands, int show_aliases);
Philippe Blain0371a762020-08-05 01:19:05 +000024void list_guides_help(void);
Ævar Arnfjörð Bjarmasond976c512022-08-04 18:28:33 +020025void list_user_interfaces_help(void);
Ævar Arnfjörð Bjarmason844739b2022-08-04 18:28:34 +020026void list_developer_interfaces_help(void);
Nguyễn Thái Ngọc Duy63eae832018-05-20 20:40:01 +020027
Denton Liu55454422019-04-29 04:28:14 -040028void list_all_main_cmds(struct string_list *list);
29void list_all_other_cmds(struct string_list *list);
30void list_cmds_by_category(struct string_list *list,
Denton Liuad6dad02019-04-29 04:28:23 -040031 const char *category);
Denton Liu55454422019-04-29 04:28:14 -040032void list_cmds_by_config(struct string_list *list);
33const char *help_unknown_cmd(const char *cmd);
34void load_command_list(const char *prefix,
Denton Liuad6dad02019-04-29 04:28:23 -040035 struct cmdnames *main_cmds,
36 struct cmdnames *other_cmds);
Johannes Schindelin722fc372020-10-07 21:56:51 +000037void load_builtin_commands(const char *prefix, struct cmdnames *cmds);
Denton Liu55454422019-04-29 04:28:14 -040038void add_cmdname(struct cmdnames *cmds, const char *name, int len);
Miklos Vajna940208a2008-07-30 01:16:58 +020039/* Here we require that excludes is a sorted list. */
Denton Liu55454422019-04-29 04:28:14 -040040void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes);
41int is_in_cmdlist(struct cmdnames *cmds, const char *name);
Ævar Arnfjörð Bjarmason06fa4db2021-09-22 00:40:39 +020042void list_commands(struct cmdnames *main_cmds, struct cmdnames *other_cmds);
Emily Shaffer617d5712020-04-16 14:18:05 -070043void get_version_info(struct strbuf *buf, int show_build_options);
Miklos Vajna940208a2008-07-30 01:16:58 +020044
Vikrant Varmae5618102013-05-04 05:34:19 +053045/*
46 * call this to die(), when it is suspected that the user mistyped a
47 * ref to the command, to give suggested "correct" refs.
48 */
René Scharfe80e36582019-08-29 21:13:16 +020049NORETURN void help_unknown_ref(const char *ref, const char *cmd, const char *error);
Nguyễn Thái Ngọc Duy3ac68a92018-05-26 15:55:24 +020050
51static inline void list_config_item(struct string_list *list,
52 const char *prefix,
53 const char *str)
54{
55 string_list_append_nodup(list, xstrfmt("%s.%s", prefix, str));
56}
57
58#define define_list_config_array(array) \
59void list_config_##array(struct string_list *list, const char *prefix) \
60{ \
61 int i; \
62 for (i = 0; i < ARRAY_SIZE(array); i++) \
63 if (array[i]) \
64 list_config_item(list, prefix, array[i]); \
65} \
66struct string_list
67
68#define define_list_config_array_extra(array, values) \
69void list_config_##array(struct string_list *list, const char *prefix) \
70{ \
71 int i; \
72 static const char *extra[] = values; \
73 for (i = 0; i < ARRAY_SIZE(extra); i++) \
74 list_config_item(list, prefix, extra[i]); \
75 for (i = 0; i < ARRAY_SIZE(array); i++) \
76 if (array[i]) \
77 list_config_item(list, prefix, array[i]); \
78} \
79struct string_list
80
81/* These are actually scattered over many C files */
82void list_config_advices(struct string_list *list, const char *prefix);
83void list_config_color_branch_slots(struct string_list *list, const char *prefix);
84void list_config_color_decorate_slots(struct string_list *list, const char *prefix);
85void list_config_color_diff_slots(struct string_list *list, const char *prefix);
86void list_config_color_grep_slots(struct string_list *list, const char *prefix);
87void list_config_color_interactive_slots(struct string_list *list, const char *prefix);
88void list_config_color_status_slots(struct string_list *list, const char *prefix);
Han-Wen Nienhuysbf1a11f2018-08-07 14:51:08 +020089void list_config_color_sideband_slots(struct string_list *list, const char *prefix);
Nguyễn Thái Ngọc Duy3ac68a92018-05-26 15:55:24 +020090void list_config_fsck_msg_ids(struct string_list *list, const char *prefix);
91
Miklos Vajna940208a2008-07-30 01:16:58 +020092#endif /* HELP_H */