From: Johannes Berg Date: Tue, 20 Nov 2012 12:47:49 +0000 (+0100) Subject: allow multiple command variants X-Git-Tag: v3.8~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb795501461f8edcaf8c5507bedf830b04807f76;p=thirdparty%2Fiw.git allow multiple command variants --- diff --git a/iw.c b/iw.c index af55a9b..63f1a61 100644 --- a/iw.c +++ b/iw.c @@ -105,9 +105,40 @@ static void __usage_cmd(const struct cmd *cmd, char *indent, bool full) if (cmd->parent && cmd->parent->name) printf("%s ", cmd->parent->name); printf("%s", cmd->name); - if (cmd->args) - printf(" %s", cmd->args); - printf("\n"); + + if (cmd->args) { + /* print line by line */ + start = cmd->args; + end = strchr(start, '\0'); + printf(" "); + do { + lend = strchr(start, '\n'); + if (!lend) + lend = end; + if (start != cmd->args) { + printf("\t"); + switch (cmd->idby) { + case CIB_NONE: + break; + case CIB_PHY: + printf("phy "); + break; + case CIB_NETDEV: + printf("dev "); + break; + case CIB_WDEV: + printf("wdev "); + break; + } + if (cmd->parent && cmd->parent->name) + printf("%s ", cmd->parent->name); + printf("%s ", cmd->name); + } + printf("%.*s\n", (int)(lend - start), start); + start = lend + 1; + } while (end != lend); + } else + printf("\n"); if (!full || !cmd->help) return;