Skip to content

Commit 213718c

Browse files
committed
Make pkg help aware of aliases
1 parent 046ab96 commit 213718c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/main.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,9 @@ exec_help(int argc, char **argv)
222222
bool plugins_enabled = false;
223223
struct plugcmd *c;
224224
unsigned int i;
225+
const pkg_object *all_aliases;
226+
const pkg_object *alias;
227+
pkg_iter it = NULL;
225228

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

270+
/* Try aliases */
271+
all_aliases = pkg_config_get("ALIAS");
272+
while ((alias = pkg_object_iterate(all_aliases, &it))) {
273+
if (strcmp(argv[1], pkg_object_key(alias)) == 0) {
274+
printf("`%s` is an alias to `%s`\n", argv[1], pkg_object_string(alias));
275+
return (0);
276+
}
277+
}
278+
267279
/* Command name not found */
268280
warnx("'%s' is not a valid command.\n", argv[1]);
269281

0 commit comments

Comments
 (0)