Skip to content

Commit

Permalink
Make pkg help aware of aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
AMDmi3 committed Jul 28, 2014
1 parent 046ab96 commit 213718c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main.c
Expand Up @@ -222,6 +222,9 @@ exec_help(int argc, char **argv)
bool plugins_enabled = false;
struct plugcmd *c;
unsigned int i;
const pkg_object *all_aliases;
const pkg_object *alias;
pkg_iter it = NULL;

if ((argc != 2) || (strcmp("help", argv[1]) == 0)) {
usage_help();
Expand Down Expand Up @@ -264,6 +267,15 @@ exec_help(int argc, char **argv)
return (0);
}

/* Try aliases */
all_aliases = pkg_config_get("ALIAS");
while ((alias = pkg_object_iterate(all_aliases, &it))) {
if (strcmp(argv[1], pkg_object_key(alias)) == 0) {
printf("`%s` is an alias to `%s`\n", argv[1], pkg_object_string(alias));
return (0);
}
}

/* Command name not found */
warnx("'%s' is not a valid command.\n", argv[1]);

Expand Down

0 comments on commit 213718c

Please sign in to comment.