help.h 3.1 KB

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