option and may change or be removed in the future. Supported
groups are: builtins, parseopt (builtin commands that use
parse-options), main (all commands in libexec directory),
- others (all other commands in `$PATH` that have git- prefix).
+ others (all other commands in `$PATH` that have git- prefix),
+ list-<category> (see categories in command-list.txt)
GIT COMMANDS
------------
test "$bit" -gt 32 && die "Urgh.. too many categories?"
}
+define_category_names () {
+ echo
+ echo "/* Category names */"
+ echo "static const char *category_names[] = {"
+ bit=0
+ category_list "$1" |
+ while read cat
+ do
+ echo " \"$cat\", /* (1UL << $bit) */"
+ bit=$(($bit+1))
+ done
+ echo " NULL"
+ echo "};"
+}
+
print_command_list () {
echo "static struct cmdname_help command_list[] = {"
"
define_categories "$1"
echo
+define_category_names "$1"
+echo
print_command_list "$1"
list_all_main_cmds(&list);
else if (match_token(spec, len, "others"))
list_all_other_cmds(&list);
+ else if (len > 5 && !strncmp(spec, "list-", 5)) {
+ struct strbuf sb = STRBUF_INIT;
+
+ strbuf_add(&sb, spec + 5, len - 5);
+ list_cmds_by_category(&list, sb.buf);
+ strbuf_release(&sb);
+ }
else
die(_("unsupported command listing type '%s'"), spec);
spec += len;
clean_cmdnames(&other_cmds);
}
+void list_cmds_by_category(struct string_list *list,
+ const char *cat)
+{
+ int i, n = ARRAY_SIZE(command_list);
+ uint32_t cat_id = 0;
+
+ for (i = 0; category_names[i]; i++) {
+ if (!strcmp(cat, category_names[i])) {
+ cat_id = 1UL << i;
+ break;
+ }
+ }
+ if (!cat_id)
+ die(_("unsupported command listing type '%s'"), cat);
+
+ for (i = 0; i < n; i++) {
+ struct cmdname_help *cmd = command_list + i;
+
+ if (cmd->category & cat_id)
+ string_list_append(list, drop_prefix(cmd->name));
+ }
+}
+
int is_in_cmdlist(struct cmdnames *c, const char *s)
{
int i;
extern void list_common_cmds_help(void);
extern void list_all_main_cmds(struct string_list *list);
extern void list_all_other_cmds(struct string_list *list);
+extern void list_cmds_by_category(struct string_list *list,
+ const char *category);
extern const char *help_unknown_cmd(const char *cmd);
extern void load_command_list(const char *prefix,
struct cmdnames *main_cmds,